more useful options | |
PerlMonks |
Perl Regex Repeating Patternsby Anonymous Monk |
on Jan 17, 2012 at 21:06 UTC ( [id://948417]=perlquestion: print w/replies, xml ) | Need Help?? |
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: Dear Monks, I have a problem I am trying to solve with regular expressions. I want to return all locations of an array of patterns inside a string. I also only want the patterns to match at locations which are a multiple of 3. For example, so far I have the following.
The problem with this is that it matches the first pattern correctly, but it will also match 'CCCDDD' in the second loop because I cannot/dont know how to anchor the pattern to start at a specific location. To be clear, I only want the patterns in the array to match if there are a number of characters evenly divisible by three before it. Is there a good way to do this? Thanks
Back to
Seekers of Perl Wisdom
|
|