A phone number verification regular expression consists of one plus sign at the beginning and previous digits

I am trying to verify the phone number but cannot.

My requirement is a phone number consisting only of numbers and + (plus a character). The + character can only be the first character.

For example: +123456489

I use this regex but it does not work:

/^\+(?:[0-9]??)$/

Thanks in advance.

+4
source share
4 answers

I would use this instead:

^\+?\d*$

Matches your + at the beginning, then any digit, dash, space, dot, or parentheses.

See in action: http://regex101.com/r/mS9gD7

+4
source

How about this?

^[\+\d]?(?:[\d-.\s()]*)$

:

test-string

: https://regex101.com/r/mS9gD7/39

+1
\+[0-9]+

Try the above regex. You can check here http://gskinner.com/RegExr/ . Do you also want to check the length?

0
source

You can try this ^ + [1-9] {1} [0-9] {10} $

-1
source

All Articles