Does grouping work inside a Perl regex character class?

consider the following code:

perl -wne 'chomp;print if m/[^(?:test)]/' 

I was surprised to see that grouping inside a character class works. How is this different from (?!pattern) ?

+6
regex perl
source share
1 answer
 /[^(?:test)]/ 

not grouped in char class. All char listed in [] after ^ will be processed literally, and this will match any string containing char except ( ? : t e s t )

+11
source share

All Articles