I have the following string, which matches the following RegEx string. I would like it to not match.
Test String: yahoo.c!om
RegEx Pattern: [\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?
Using an online tester, I can validate that “yahoo.c!om” matches. I can’t figure out how modify the RegEx pattern to make it NOT match. Does anyone have any ideas? This RegEx stuff makes me want to jump off a building.
The
.in regex matches any character (other than line breaks). So the.in:matches the
!fromyahoo.c!om. Escape the.to match the literal.instead:That way,
yahoo.c!omwon’t match entirely.You may want to “anchor” your regex with the “start”- and “end-of-input” meta characters (
^and$respectively):