正则表达式不包含字符串与包含字符串匹配

不包含字符串 ABC:
^(?!.*ABC).*$
(参考: https://www.cnblogs.com/wangqiguo/archive/2012/05/08/2486548.html)

不包含字符串 ABC 且 包含字符串 XYZ:
^((?!ABC).)*XYZ((?!ABC).)*$
(参考: https://www.cnblogs.com/mumian2/p/10926361.html)

猜你喜欢

转载自blog.csdn.net/hegan2010/article/details/104988396