javascript regex: matching a phone number

前端 未结 1 1568
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 20:28

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/         


        
1条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-27 21:12

    Lose the quotes:

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

    0 讨论(0)
提交回复
热议问题