I am using this regex to match any string other than foo:
^((?!(foo)).)*
It succeeds in matching and capturing anything other than foo but it also matches foo, just with no capture. Is there a way to make it not match foo at all?
I am using this regex to match any string other than foo:
^((?!(foo)).)*
It succeeds in matching and capturing anything other than foo but it also matches foo, just with no capture. Is there a way to make it not match foo at all?
You must use anchor
$
also:RegEx Demo