开发者

javascript regex: matching a phone number

how do I match this phone number in Javascript?

> str
"(555) 555-3300"
> str.match( '/\(555\) 555-3300/gi/' )
null
> str.match( '/(555) 555-3300/gi/' )
null

I bet someone can 开发者_运维问答answer this in 2 seconds. Googling the problem didn't help me.

Update

Also tried without the quotes:

str.match(/\(555\) 555-3300/gi/)
SyntaxError: Unexpected token )

Ultimately I'm trying to replace the phone number with a different one.


Lose the quotes:

str.match(/\(480\) 945-3300/g)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜