Home  >  Article  >  Backend Development  >  求php正则表达式,不能以abc或xyz结尾

求php正则表达式,不能以abc或xyz结尾

WBOY
WBOYOriginal
2016-06-06 20:15:34906browse

求php正则表达式,不能以字符串abc或xyz结尾
如果是单个,不能以字符串abc结尾应该是:([^abc]$/i)吧?

回复内容:

求php正则表达式,不能以字符串abc或xyz结尾
如果是单个,不能以字符串abc结尾应该是:([^abc]$/i)吧?

/^(?!.*abc$)(?!.*xyz$)/

[]这个结构的意思是里面的元素都是每个小分支呀
所以题主所说的
[^abc]$/i是不严格的,
比如,

/[^abc]$/i.test("xxxab"); //false 实际上你希望得到true

/.*?[^(abc|xyz)]$/i
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn