Re: non-greedy is too greedy
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: non-greedy is too greedy

From: Erik Leunissen <look@the.footer.invalid>
Date: Thu Jun 30 2005 - 16:03:32 CEST

Markus.Elfring@web.de wrote:
>
> Does the following example show another unexpected result for you?
>
> % regexp {^|(.+?)|} {|A|B|} X field
> 1
> % set field
> |A|B|
>

After having understood the following documented behaviour:

"An RE consisting of two or more branches connected by the | operator
prefers longest match."

and having looked very hard at {^|(.+?)|}, I have trouble combining the
two, without arriving at a conclusion as to what it should do.

So, unexpected? ... no, not yet; mainly headache and inconclusiveness.

Thanks for the riddle ;-)

Erik

-- 
   leunissen@       nl | Merge the left part of these two lines into one,
e.          hccnet.   | respecting a character's position in a line.
Received on Thu Sep 29 14:24:04 2005