开发者

Very Simple Regex

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜