xxxxxxNNNGYGYxxxxxxxGYGYNNNxxxxxxxNNNGNNNxxxxxxx
NNG
YGY
GYG
NNG
xxxxxxNNNGYGYxxxxxxxGYGYNNNxxxxxxxNNNGNNNxxxxxxx
NNGYGY
GYGY
NNG
whereas I would have expected
xxxxxxNNNGYGYxxxxxxxGYGYNNNxxxxxxxNNNGNNNxxxxxxx
NNGYGY
GYGYNN
NNGNN
| [reply] [d/l] [select] |
I didn't read the question that way, but now you've pointed it out, yours could be, and probably is the more correct interpretation.
If the regex engine wouldn't insist that, any reference to a previous capture, in a negative look-behind assertion, *must* be variable length (and therefore disallowed), even when the brackets referenced can only, and must, capture exactly one char.
Then it would be easy to fix this to meet your interpretation of the problem. Alas it does, so there isn't :)
I cannot see fix at the moment.
Examine what is said, not who speaks.
"But you should never overestimate the ingenuity of the sceptics to come up with a counter-argument." -Myles Allen
"Think for yourself!" - Abigail
"Time is a poor substitute for thought"--theorbtwo
"Efficiency is intelligent laziness." -David Dunham
"Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
| [reply] |
/([QGYN]{2} # First two characters of the desired class
(?: # Followed by the complex expression...
# Look for a trio starting two characters back
(?<=(?!(.)\2\2)..)
[QGYN] # Then take another of the desired class
){1,4} # ...1 to 4 times
)/gx
This was a trick someone posted some time ago, but it was over my head at the time. Now I get it.
Caution: Contents may have been coded under pressure.
| [reply] [d/l] |