help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Perl, etc has these "?"-prefix modifiers/codes/whatever. Precisely w


From: Tim Landscheidt
Subject: Re: Perl, etc has these "?"-prefix modifiers/codes/whatever. Precisely which does emacs have (and NOT have)?
Date: Tue, 23 Feb 2010 12:33:02 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

John Withers <grayarea@reddagger.org> wrote:

> You are completely correct on all counts. What I should have said was
> that for many classes of problems I run into during my daily work the
> ability to write a regex is much faster than using a parser (and
> definitely than writing one). And that I find the classes of problems
> that fit that mold increased by having lookahead/behind assertions.

> I use parsers more frequently than I use regexes, but a lot of the one
> shot work I do on logs, semi-structured text files of various types and
> in very, very limited cases some html where the html is already
> processed in some way; a quick regex is much faster for me, and I
> imagine almost everyone, but I could be wrong.
> [...]

Same with me; and I would add that the maintainability in-
creases drastically as well. If I have to revisit a term
like:

| (while (re-search-forward "foo" nil t)
|   (save-match-data
|     (when (not (looking-at "bar"))
|       (replace-match "XYZ")))))

or even:

| foo\($\|[^b]\|b[^a]\|ba[^r]\)

I need much more time to understand what I tried to achieve
than with:

| foo(?!bar)

Furthermore, if the handmade parser has a subtle deviation
from what you would expect it to look like, you spend even
more time figuring out whether that was a wanted effect or a
bug not yet discovered.

Tim


reply via email to

[Prev in Thread] Current Thread [Next in Thread]