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

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

Re: regexp question: match anything but not a group?


From: Thorsten Jolitz
Subject: Re: regexp question: match anything but not a group?
Date: Thu, 03 Apr 2014 21:36:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Andreas Röhler <andreas.roehler@easy-emacs.de> writes:

> Am 01.04.2014 23:30, schrieb Thorsten Jolitz:
>>
>> Hi List,
>>
>> how can I write a regexp that acts like e.g.
>>
>> ,------
>> | ".*?"
>> `------
>>
>
> BTW looks wrong. .* might much nothing, if non-greedy it remains
> nothing (?)

But it still seems valid to protect against greedyness?

,---------------------------------------------------------------------
| '*?', '+?', '??'
|     These are "non-greedy" variants of the operators '*', '+' and '?
|     '. Where those operators match the largest possible substring
|     (consistent with matching the entire containing expression), the
|     non-greedy variants match the smallest possible substring
|     (consistent with matching the entire containing expression).
|    
|     For example, the regular expression 'c[ad]*a' when applied to
|     the string 'cdaaada' matches the whole string; but the regular
|     expression 'c[ad]*?a', applied to that same string, matches just
|     'cda'. (The smallest possible match here for '[ad]*?' that
|     permits the whole expression to match is 'd'.)
`---------------------------------------------------------------------


-- 
cheers,
Thorsten




reply via email to

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