I was wondering how to write this regular expression differently:
$line !~ /this that( now| other)/
Here is the catch, I have to use “=~” instead of “!~”. Is there a way of doing this? I can’t seem to figure it out.
What’s happening is I’m passing this pattern into a method where the =~ is hardcoded. I want to match a phrase with a certain prefix (“this that” in this case) but not if it has certain suffixes (" now" or " other" in my above example). I can’t seem to figure this out. Thanks!
In general it’s not possible to take a RE and convert it a simple RE for the complement language. Although the complement of a regular language is also regular, it might not be simple to specify.