Re: Stingy matching

2006-07-01 Thread Mr. Shawn H. Corey
On Sat, 2006-01-07 at 01:29 +0200, Filip Jursik wrote: > Well, I thought, that when I write: > 1) /A(.*)B/, $1 will hold the longest string enclosed by A and B > 2) /A(.*?)B/, $1 will hold the shortest string enclosed by A and B > > Does it work like this or the "?" after the ".*" has a different

Re: Stingy matching

2006-07-01 Thread Dr.Ruud
Rob Dixon schreef: > Filip Jursik: >> $text = "first first second third"; >> $text =~ /(first.*?third)/; >> print $1; >> gives me >> "first first second third" >> as a result instead of expected >> "first second third" > > The regex engine will match one element at a time. Your

Re: Stingy matching

2006-07-01 Thread Dr.Ruud
Filip Jursik schreef: > $text = "first first second third"; > $text =~ /(first.*?third)/; > print $1; > > gives me > > "first first second third" > > as a result instead of expected > > "first second third" The match starts at the first possible position, or in other words: *? doesn't look back.

Re: Stingy matching

2006-07-01 Thread Filip Jursik
!!! THANK YOU! :) F. Rob Dixon wrote: Filip Jursik wrote: Hi, this $text = "first first second third"; $text =~ /(first.*?third)/; print $1; gives me "first first second third" as a result instead of expected "first second third" What am I doing wrong? I've expected the .*? to limit th

Re: Stingy matching

2006-07-01 Thread Filip Jursik
Mr. Shawn H. Corey wrote: On Fri, 2006-30-06 at 23:04 +0200, Filip Jursik wrote: Hi, this $text = "first first second third"; $text =~ /(first.*?third)/; print $1; gives me "first first second third" as a result instead of expected "first second third" What am I doing wrong? I've expected

Re: Stingy matching

2006-06-30 Thread Rob Dixon
Filip Jursik wrote: Hi, this $text = "first first second third"; $text =~ /(first.*?third)/; print $1; gives me "first first second third" as a result instead of expected "first second third" What am I doing wrong? I've expected the .*? to limit the wildcard only to the string " second ".

Re: Stingy matching

2006-06-30 Thread John W. Krahn
Filip Jursik wrote: > Hi, Hello, > this > > $text = "first first second third"; > $text =~ /(first.*?third)/; > print $1; > > gives me > > "first first second third" > > as a result instead of expected > > "first second third" > > What am I doing wrong? I've expected the .*? to limit the wi

Re: Stingy matching

2006-06-30 Thread Mr. Shawn H. Corey
On Fri, 2006-30-06 at 23:04 +0200, Filip Jursik wrote: > Hi, > > this > > $text = "first first second third"; > $text =~ /(first.*?third)/; > print $1; > > gives me > > "first first second third" > > as a result instead of expected > > "first second third" > > What am I doing wrong? I've exp

Re: Stingy matching

2006-06-30 Thread Joshua Colson
On Fri, 2006-06-30 at 23:04 +0200, Filip Jursik wrote: > Hi, > > this > > $text = "first first second third"; > $text =~ /(first.*?third)/; > print $1; > > gives me > > "first first second third" > > as a result instead of expected > > "first second third" > > What am I doing wrong? I've exp

Stingy matching

2006-06-30 Thread Filip Jursik
Hi, this $text = "first first second third"; $text =~ /(first.*?third)/; print $1; gives me "first first second third" as a result instead of expected "first second third" What am I doing wrong? I've expected the .*? to limit the wildcard only to the string " second ". Thanx, F. -- To