[英]Regex digits with length and some specific characters
I have a phone number input field where it must: 我必须在其中输入电话号码:
I tried but my best result was ng-pattern="/^\\+?\\d{0,11}?$/"
. 我尝试过,但最好的结果是
ng-pattern="/^\\+?\\d{0,11}?$/"
。
How to make this work? 如何使这项工作?
Seems like you're trying to match a phone number? 好像您要匹配电话号码? Maybe this is helpful: What regular expression will match valid international phone numbers?
也许这会有所帮助: 哪些正则表达式将与有效的国际电话号码匹配?
Otherwise, if no particular order or restrictions for your numbers, +
, -
or spaces, this should do the work: /^[0-9\\+\\-\\s]{1,12}$/
否则,如果对您的数字
+
, -
或空格没有特定的顺序或限制,则应执行以下操作: /^[0-9\\+\\-\\s]{1,12}$/
https://regex101.com/r/kuc5OF/2 https://regex101.com/r/kuc5OF/2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.