actually I tried this before posting this question. The issue is that regex stops after first match. The output is: name: name1
I did put /g at the end, but results are the same. Regards On Mon, Apr 14, 2008 at 9:11 PM, Gary Stainburn <[EMAIL PROTECTED]> wrote: > On Monday 14 April 2008 16:35, Sharan Basappa wrote: > > Hi, > > > > I am trying to capture the text between two tokens. These tokens > > always exist in pairs but can occur N times. > > I somehow dont get what I want. > > > > > $str =~ m/tokena(.*)tokenb/ms; > > print $1; > > > Try > > > $str =~ m/tokena(.*?)tokenb/ms; > > The ? after the * stops it being greedy - i.e. it stops at the 1st tokenb and > not the last > > Gary > -- > Gary Stainburn > > This email does not contain private or confidential material as it > may be snooped on by interested government parties for unknown > and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > http://learn.perl.org/ > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
