Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does grouping work inside a Perl regex character class?

Tags:

regex

perl

consider the following code:

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

I was surprised to see that grouping inside a character class works, How does this differ from (?!pattern)?

like image 734
piotr Avatar asked Feb 26 '10 10:02

piotr


1 Answers

/[^(?:test)]/

is not grouping within the char class. All the char listed in the [ ] after ^ will be treated literally and this will match any string that contains char other than ( ? : t e s t )

like image 60
codaddict Avatar answered Sep 22 '22 03:09

codaddict