How to do equivalent of /(regexp){0}/ ?

I don't want to have to resort to

 
/([^s][^t][^r][^i][^n][^g])/

though that does work.

Effectively, I need to be able to implement

 
/(?:(?:regexp1){0}[^-0-9])(regexp2)\D/

to basically match regexp2 as long as it is present and regexp1 is NOT.

So, how to do

 
/(regexp){0}/

?

You need a zero-width negative look-behind assertion from the extended patterns. Example:

$ cat /tmp/test.txt
This should be matched.
This should not be matched.
$ perl -ne 'print if /(?<!not\s)be/;' /tmp/test.txt
This should be matched.
$
1 Like

That's what I get for not reading the entire perlre doc. :stuck_out_tongue: