I'm trying to write a regex to match any string that is not empty or equals to www.
Example:
www => don't match
ww => match
adwww => match
wwwad => match
abcde => match
My regex:
(.+)(www)
How can I fix my regex?
You need a lookahead based regex:
^(?!www$).+
See the regex demo.
Details:
^ - start of string(?!www$) - the string cannot be equal to www.+ - 1 or more characters (other than a line break if you do not use a DOTALL modifier)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With