开发者

Very Simple Regex

开发者 https://www.devze.com 2022-12-29 03:09 出处:网络
I want a regular expression which will ignore the sentence containing \"XYZ\" character. I am开发者_高级运维 using this but this is not working

I want a regular expression which will ignore the sentence containing "XYZ" character. I am开发者_高级运维 using this but this is not working

<td>(.+[^XYZ])</td>


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消