Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phone numbers with regex (plus and spaces) [duplicate]

I am trying to catch all these numbers with a regex but I can't find a pattern.

Criteria for numbers:

  1. Numbers can start with "00"
  2. Numbers can start with "+"
  3. Numbers can contain spaces between them.

it may be that before or after the phone number you have text.

Regex:

\b[\+]?[(]?[0-9]{2,6}[)]?[-\s\.]?[-\s\/\.0-9]{3,15}\b

Sample phone Numbers:

00491234567890
+491234567890

0123-4567890

0123 4567 789
0123 456 7890
0123 45 67 789

+490123 4567 789
+490123 456 7890
+49 123 45 67 789

123 4567 789
123 456 7890
123 45 67 789


+49 1234567890
+491234567890

0049 1234567890
0049 1234 567 890

(0049)1234567890
(+49)1234567890

(0049) 1234567890
(+49) 1234567890



text text (0049) 1234567890 text text
text text (+49) 1234567890 text text

Thanks.

like image 478
victorelec14 Avatar asked Mar 31 '20 11:03

victorelec14


People also ask

How do you validate a phone number using a validator?

Mobile Number validation criteria: The first digit should contain number between 7 to 9. The rest 9 digit can contain any number between 0 to 9. The mobile number can have 11 digits also by including 0 at the starting. The mobile number can be of 12 digits also by including 91 at the starting.


Video Answer


1 Answers

I've written this regex to find phone numbers:

(\(?(0{1,2}|\+)\d{1,2}\)?)?([ -]*\d+)+
like image 117
Aplet123 Avatar answered Oct 17 '22 12:10

Aplet123