theshz has asked for the wisdom of the Perl Monks concerning the following question:
It didn't quite do what I want. I'd like it to match 3 times:# To find all occurance of "bc" preceeded by 3 letters, and followed b +y 2 letters. $str = "aaabcabcdebcaabebcb"; while($str =~ /(\w{3}bc\w{2})/g){ print "$-[1],$+[1],$1\n"; } __OUTPUT__ 0,7,aaabcab 7,14,cdebcaa
Thanks.__OUTPUT__ 0,6,aaabcab 3,9,bcabcde 7,13,cdebcaa
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex: continuous matching positions
by Tanktalus (Canon) on Apr 26, 2006 at 15:45 UTC | |
|
Re: Regex: continuous matching positions
by japhy (Canon) on Apr 26, 2006 at 16:07 UTC | |
|
Re: Regex: continuous matching positions
by duff (Parson) on Apr 26, 2006 at 15:48 UTC |