Regex for country code

前端 未结 4 1344
日久生厌
日久生厌 2020-12-20 21:12

I\'m trying to write a regex for country code, which should limit to four characters maximum, only symbol allowed is a + sign. When the + is used, the + has to be in the beg

4条回答
  •  太阳男子
    2020-12-20 21:54

    country codes can be of following types

    • +1
    • +91
    • +223
    • +1-224

    The javascript regex that makes sure that the input is one if the

    /^\+(\d{1}\-)?(\d{1,3})$/
    

提交回复
热议问题