in reply to Re^2: Integrating match counts into regex matching
in thread Integrating match counts into regex matching
Indeed++ Hence the "Hmmm?"
It can be dealt with:
for( qw[ ab abb abbb aabb aabbb aabbbb a_abb a_abbb abbaabbbaaabbbaxab +b ] ) { print "$_ contains '$1'" while m[ ( (?<!a) (?{ local $a }) ( a (?{++$a}) )+ ( ?{ local $b }) ( b (?{++$b}) )+ (?!b ) ) (?(?{ $a+1 == $b }) (?=) | (?!) ) ]gx };; abb contains 'abb' aabbb contains 'aabbb' a_abb contains 'abb' abbaabbbaaabbbaxabb contains 'abb' abbaabbbaaabbbaxabb contains 'aabbb' abbaabbbaaabbbaxabb contains 'abb'
But yours is a simpler approach, and probably quicker.
But the primary purpose of posting was to demonstrate the regex if...then...else construct--not to do someone else's systems testing for them.
Particularly as this is very unlikely to be the actual pattern they are trying to match
|
---|