What is the difference in PCRE pattern: `(?!or|and)\w+` and `[(?!or|and)\w]+`?

15 Views Asked by At

What I want to capture is some variable/call expressions without or or and keywords. As the title says, what is the difference between (?!or|and)\w+ and [(?!or|and)\w]+ ? I'm sure those are different, because for the following pattern:

...
if (var_select is False) or (var_select in SOME_GLOBAL_ARRAY):
...

pcregrep -r 'if (?!or|and)\w+ is False' fails to capture this pattern, but pcregrep -r 'if [(?!or|and)\w]+ is False' does. What does [...] mean in the context of having (?!...) and \w together?

0

There are 0 best solutions below