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

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

Re: Help with regexp


From: Stefan Monnier
Subject: Re: Help with regexp
Date: Wed, 02 Dec 2009 22:48:40 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux)

>> > Hi,
>> >
>> > I am trying to find the regexp that could match on these:
>> >
>> > "=>foo"

> [...]

>> "=>\\([^:]*\\(\\|:[^:]*\\(\\|:[^:]*\\)\\)\\)"

> Wow, Pascal. You have taught this old dog a new trick. Up to now, I
> hadn't thought of putting an alternative (i.e. "|") at the start of a
> parenthesized sub-expression. Thanks :-)

An equivalent way is to use ? (or ?? if you care about the order in
which it's matched):

  "=>\\([^:]*\\(:[^:]*\\(:[^:]*\\)?\\)?\\)"


        Stefan


reply via email to

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