in reply to Re^3: JAVA [[a-z]&&[^aeiou]] equivalence
in thread JAVA [[a-z]&&[^aeiou]] equivalence
So it's not an exclusive Perl thing.
See this JS doc for instance:
Lookahead_assertion#pattern_subtraction_and_intersection¹
It's also worth discussing the pro and cons of the regex-sets solution posted by choroba.
The lookaheads are generic and not restricted to character classes and allow combining any kind of patterns.
But in the case of handling character classes only, I expect the regex-class solution to be faster and better readable.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
¹) Using lookahead, you can match a string multiple times with different patterns, which allows you to express complex relationships like subtraction (is X but not Y) and intersection (is both X and Y).
|
---|