Phone numbers with regex (plus and spaces)

Viewed 355

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.

2 Answers

I've written this regex to find phone numbers:

(\(?(0{1,2}|\+)\d{1,2}\)?)?([ -]*\d+)+

I made a workaround on this. Let me know if this helps

^(\d|\+)[ \d-]+$
Related