简体   繁体   English

jQuery验证引擎:反转正则表达式匹配

[英]JQuery Validation Engine : invert regex match

I am using JQuery Validation Engine, and I'd like to prevent any phone number in a text field. 我正在使用JQuery验证引擎,并且想防止文本字段中出现任何电话号码。

I have this expression, which matches any French phone numer : 我有这个表达式,它与任何法国电话号码匹配:

((\+|00)33\s?|0)[1-9](\-?\.?\s?\d{2}){4}

It matches the numbers like that: 它匹配这样的数字:

0102030405, 01.02.03.04.05, 01-02-03-04-05, +33102030405, 0033102030405, etc... 0102030405、01.02.03.04.05、01-02-03-04-05,+ 33102030405、0033102030405等...

But I need to invert this matchs, and this does not work : 但是我需要反转这个匹配项,这是行不通的:

!(((\+|00)33\s?|0)[1-9](\-?\.?\s?\d{2}){4})

You can invert the regular expression using a negative lookahead : 您可以使用负前瞻来反转正则表达式:

^((?!((\+|00)33\s?|0)[1-9](\-?\.?\s?\d{2}){4}).)*$

See also: https://stackoverflow.com/a/38846455 另请参阅: https : //stackoverflow.com/a/38846455

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM