0

我正在为我使用模式属性,<input type="tel" />并且我在使用正则表达式时遇到了困难。我尝试了 pattern="d{10]"和 pattern="d{3}[\)]\d{3}[\-]\d{4}"但它不起作用。

4

2 回答 2

0

改用这个:

pattern="\(\d{3}\) \d{3}-\d{4}"

这是小提琴: http: //jsfiddle.net/ZMaXA/
尝试弄乱input.

于 2013-02-01T15:36:19.050 回答
0
Python 2.7.3 (default, Aug  1 2012, 05:14:39) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> str='(777) 777-9087'
>>> r=re.search('\(([^\)]+)\)\s*(\d+-\d+)',str)
>>> r.groups()
('777', '777-9087')
于 2013-02-01T15:45:39.690 回答