
Regular expression problem: "|" interferring with ".*?"
Quote:
> In tclsh8.3:
> % set a "012012012012"
> 012012012012
> % regexp -inline "0.*?2" $a
> 012
> % regexp -inline "0.*?2|x" $a
> 012012012012
> Why adding a branch to the pattern makes "*?" greedy?
I've passed this onto Henry Spencer for clarification (this is
new for the 8.1+ regexp). As a work-around you can use:
(tkcon) 60 % regexp -inline {0[^2]*2|x} $a
012
(tkcon) 61 % regexp -inline {0[^2]*2} $a
012
--
Jeffrey Hobbs The Tcl Guy
jeffrey.hobbs at scriptics.com Scriptics Corp.