I've tried this
Regex:
^(?:(?![_]{2}).)+$
Text:
abcc..abc
abcdefgh_
abcd_abcd
abc_a_abc
abc__abcd
a__abcde_
abc++abcd
where highlight texts mean match.
The regex above is literally mean "match any line that constructed from any characters except __
", I just wonder about evaluation process of this regex, in my understanding the process suppose to work like this
Consider text: abc__abcd
Evaluation process:
- check condition
^
(match). - check condition
.+
(match). - check condition
$
(match).
So far, all regex still can match to our considered text.
- check condition of negative lookahead.
(?![_]{2})a(?![_]{2})b(?![_]{2})c(?![_]{2})_(?![_]{2})_(?![_]{2})a(?![_]{2})b(?![_]{2})c(?![_]{2})d
negative lookahead executing:
(?![_]{2}) ab (match)
(?![_]{2}) bc (match)
...
(?![_]{2})__ (not match)
...
Is my understanding correct?