I was using RegEx to validate user phone numbers. I have set of requirements for phone number validation. I dont have much idea about the RegEX. can anyone help me to provid
based on you samples try this pattern.
^(?:\+?\d{2}[ -]?[\d -][\d -]+)$
Just to help you build some concepts.
The following regex would match the first seven inputs you provided.
/^\+?\d{2}[- ]?\d{3}[- ]?\d{5}$/
\+? would match a + sign. The ? in it makes the + sign optional.
\d{2} matches two digits
[- ]? matches either a - or a (space). ? makes the occurrence of - or (space) optional.
\d{5} then matches 5 digits.
^ and $ are the start and end anchors.
Based on your samples, try this:
^(?:\+?\d{2}[ -]?\d{3}[ -]?\d{5}|\d{4})$
It will match all the correct values.
DESCRIPTION:

DEMO:
http://regexr.com?340nf