Hello
I want a regular expression which will ignore the sentence containing "XYZ" character. I am using this but this is not working
"(.+[^XYZ])"
Thanks in advance
Hello
I want a regular expression which will ignore the sentence containing "XYZ" character. I am using this but this is not working
"(.+[^XYZ])"
Thanks in advance
To match a line not containing the string "XYZ" you can use a negative lookahead:
^(?:(?!XYZ).)*$
If you just want to check that the line doesn't contain any of those characters in any position, use a negative character class:
^[^XYZ]*$
"(.+[^XYZ])" means "at least one character followed by neither X,Y,Z.
Matching anything that doesn't contain X,Y,Z works with "([^XYZ]*)", or "([^XYZ]+)" if you want want empty matches.