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


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."