How To Negate Regex [duplicate]

青春壹個敷衍的年華 提交于 2019-11-28 22:34:17

Use negative lookahead for this.

(?!foo123).+

matches any string except foo123

If you want to match empty string also, use (?!foo123).*

In your case (according to the comment) the required regex is (?!P[0-9]{1,}).+.

It matches P and 123, but not P123.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!