Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Christian Gollwitzer Newsgroups: comp.lang.python Subject: Re: PyMatch Tool. Date: Mon, 18 Aug 2014 19:38:54 +0200 Organization: A noiseless patient Spider Lines: 33 Message-ID: References: <198ac789-f8e3-4f81-b10f-d7b29c25a70f@googlegroups.com> <36bc5245-ebbf-4358-9b8e-1f5ef58ff0d7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 18 Aug 2014 17:38:53 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="0ca390f552aaaca2fd2a25e51821864b"; logging-data="22859"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19nokj9wQmmaaOK4Xtnw10/Daxd4Didcos=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <36bc5245-ebbf-4358-9b8e-1f5ef58ff0d7@googlegroups.com> Cancel-Lock: sha1:ilQvtcgQwUAFIJHpcOJon/no7QA= Xref: csiph.com comp.lang.python:76497 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