in reply to Re: doubt in matching
in thread doubt in matching
The /i flag only does something is you have a literal alphabetic character in the pattern. The /s only does something if you have a dot, . in the pattern. The sequence (\1{1,}) is really just \1+. :)
$_="theeee"; if( m/\w*?(\w+)(\1+)/ ) { print "\$&: $&\n\$1: $1\n\$2: $2\n"; }
I'm not sure what's supposed to end up where, but the pattern /\w*(\w+)(\1+)/ puts must of the stuff into the first part, \w*, because it's greedy and Perl is going to back track only as far as it needs to so it satisfies that next things. If you want more stuff in the ending parts, you have to make the first part non-greedy.
$_="theeee"; if( m/\w*?(\w+)(\1+)/ ) { print "\$&: $&\n\$1: $1\n\$2: $2\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: doubt in matching
by uva (Sexton) on Feb 13, 2006 at 09:20 UTC | |
by Samy_rio (Vicar) on Feb 13, 2006 at 09:40 UTC | |
by McDarren (Abbot) on Feb 13, 2006 at 09:47 UTC |