Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76329 > unrolled thread

PyMatch Tool.

Started byrafinha.unix@gmail.com
First post2014-08-14 12:50 -0700
Last post2014-08-18 13:14 -0700
Articles 7 — 5 participants

Back to article view | Back to comp.lang.python


Contents

  PyMatch Tool. rafinha.unix@gmail.com - 2014-08-14 12:50 -0700
    Re: PyMatch Tool. Chris Angelico <rosuav@gmail.com> - 2014-08-15 08:49 +1000
    Re: PyMatch Tool. Skip Montanaro <skip@pobox.com> - 2014-08-14 19:31 -0500
    Re: PyMatch Tool. Christian Gollwitzer <auriocus@gmx.de> - 2014-08-15 22:59 +0200
      Re: PyMatch Tool. Rafael Francischini <rafinha.unix@gmail.com> - 2014-08-18 05:21 -0700
        Re: PyMatch Tool. Christian Gollwitzer <auriocus@gmx.de> - 2014-08-18 19:38 +0200
          Re: PyMatch Tool. Rafael Francischini <rafinha.unix@gmail.com> - 2014-08-18 13:14 -0700

#76329 — PyMatch Tool.

Fromrafinha.unix@gmail.com
Date2014-08-14 12:50 -0700
SubjectPyMatch Tool.
Message-ID<198ac789-f8e3-4f81-b10f-d7b29c25a70f@googlegroups.com>
Hello, I created this tool to help me develop on formatting text using regular expressions. 
Any questions, I am available. 
Thank you.

Tool -> https://github.com/rfunix/PyMatch

[toc] | [next] | [standalone]


#76332

FromChris Angelico <rosuav@gmail.com>
Date2014-08-15 08:49 +1000
Message-ID<mailman.13011.1408056559.18130.python-list@python.org>
In reply to#76329
On Fri, Aug 15, 2014 at 5:50 AM,  <rafinha.unix@gmail.com> wrote:
> Hello, I created this tool to help me develop on formatting text using regular expressions.
> Any questions, I am available.
> Thank you.
>
> Tool -> https://github.com/rfunix/PyMatch

How is this better than GNU sed?

ChrisA

[toc] | [prev] | [next] | [standalone]


#76338

FromSkip Montanaro <skip@pobox.com>
Date2014-08-14 19:31 -0500
Message-ID<mailman.13014.1408062666.18130.python-list@python.org>
In reply to#76329
On Thu, Aug 14, 2014 at 5:49 PM, Chris Angelico <rosuav@gmail.com> wrote:
>
> > Tool -> https://github.com/rfunix/PyMatch
>
> How is this better than GNU sed?

I didn't look closely at the program, but I have an idea how I might use it.

Back in the dawn of Internet time (before Y2K, Django, V8, etc) I
developed and maintained a concert calendar website. It had a database
of tour dates, and a bunch of handwritten HTML. And, I allowed people
to describe their concert tour information in a
slightly-higher-than-regex level (SLTRL). This facility allowed me to
routinely process known tour date listings and update my listings with
little, if any, manual intervention.  Under the covers, of course, it
used regular expressions. I had, as they say, two problems.

My solution to failed matches (I was actually the heaviest user of the
system) was to provide a <textarea> where you could paste in some tour
dates as they appeared on an artist's website, then enter the SLTRL
notation you thought described the dates. Most of the time things were
pretty easy to handle, but every now and then it would fail. I would
then start lopping of chunks of the SLTRL from the right and see if
anything now matched, and if so, what was leftover.

This tool might work in a similar fashion. Run it repeatedly on the
same input with ever-more-complex patterns and groups until it matches
everything. Then you're done and you paste the ugly mess into your
code.

Then you have two problems. <wink>

Skip

[toc] | [prev] | [next] | [standalone]


#76386

FromChristian Gollwitzer <auriocus@gmx.de>
Date2014-08-15 22:59 +0200
Message-ID<lslsbg$qqt$1@dont-email.me>
In reply to#76329
Am 14.08.14 21:50, schrieb rafinha.unix@gmail.com:
> Hello, I created this tool to help me develop on formatting text using regular expressions.
> Any questions, I am available.
> Thank you.
>
> Tool -> https://github.com/rfunix/PyMatch

I expected something like visual regexp:

	http://laurent.riesterer.free.fr/regexp/

Since RegExp-Syntax is very similar across tools, yours is almost 
identical to grep. Is it not?

	Christian

[toc] | [prev] | [next] | [standalone]


#76470

FromRafael Francischini <rafinha.unix@gmail.com>
Date2014-08-18 05:21 -0700
Message-ID<36bc5245-ebbf-4358-9b8e-1f5ef58ff0d7@googlegroups.com>
In reply to#76386
Em sexta-feira, 15 de agosto de 2014 17h59min28s UTC-3, Christian Gollwitzer  escreveu:
> Am 14.08.14 21:50, schrieb rafinha.unix@gmail.com:
> 
> > Hello, I created this tool to help me develop on formatting text using regular expressions.
> 
> > Any questions, I am available.
> 
> > Thank you.
> 
> >
> 
> > Tool -> https://github.com/rfunix/PyMatch
> 
> 
> 
> I expected something like visual regexp:
> 
> 
> 
> 	http://laurent.riesterer.free.fr/regexp/
> 
> 
> 
> Since RegExp-Syntax is very similar across tools, yours is almost 
> 
> identical to grep. Is it not?
> 
> 
> 
> 	Christian

Hi Christian, it is quite similar. 
The difference is with her can extract and use the values stored in groups.

[toc] | [prev] | [next] | [standalone]


#76497

FromChristian Gollwitzer <auriocus@gmx.de>
Date2014-08-18 19:38 +0200
Message-ID<lstdnd$mab$1@dont-email.me>
In reply to#76470
Am 18.08.14 14:21, schrieb Rafael Francischini:
> Em sexta-feira, 15 de agosto de 2014 17h59min28s UTC-3, Christian Gollwitzer  escreveu:
>>
>> I expected something like visual regexp:
>> 	http://laurent.riesterer.free.fr/regexp/
>>
>> Since RegExp-Syntax is very similar across tools, yours is almost
>>
>> identical to grep. Is it not?
>>
>>
>>
>> 	Christian
>
> Hi Christian, it is quite similar.
> The difference is with her can extract and use the values stored in groups.
>

I guess you haven't tried visual regexp. It marks the regexp parts and 
what it matches with distinct colors - Look at the screenshot. The 
C++-code looks like syntax highlighting. But visual regexp does the 
coloring automatically just by looking at the regexp. For example, the 
word "template" is colored blue, because it was matched by \w+ (also 
colored blue in the expression).

Your tool seems to only extract pure text. This can be done using sed, e.g.:

	sed 's/(.* some re)/place \1 here/'

The \1 is replaced with the first () group, \2 with the second etc. From 
within Python, you can use re.sub, which also accepts backreferences.

	Christian

[toc] | [prev] | [next] | [standalone]


#76507

FromRafael Francischini <rafinha.unix@gmail.com>
Date2014-08-18 13:14 -0700
Message-ID<97be548c-dc08-4b0e-ba78-53b14d291cb2@googlegroups.com>
In reply to#76497
Cristian you are right, never experienced visual regexp, is incredible. 
I created pyMatch to help me in the automation scripts and text formatting, so I decided to work from the command line. 
You're right, you can also do this with sed, but sed has a small defect "in my view", you will be able to use a maximum of 10 groups in it and  also the visual regexp. 

If you want to read more: http://stackoverflow.com/questions/10992650/how-to-get-10th-grouping-value-in-sed

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web