The easiest approach when you have only negative matching conditions is to create a positive regular expression and then check that it does not match.
if ($string !~ /\.js$/) { print "Doesn't end in .js"; }
This is easier to understand and more effective than a negative appearance.
Workarounds are needed only when you need to mix positive and negative conditions (for example, "I need to match" foo "from a string, but only when it does not follow" bar "). Sometimes itβs easier to use some simple patterns and logic instead of meeting all your requirements with one complex template.
user1919238
source share