0

I am trying to extract phone number from text my problem is that my regex currently matches the bold parts of the

+00 000 000 0000
+00.000.000.0000
+00-000-000-0000
+000000000000

but it should not be matched become it starts with a + and the country code (+00) doesn't exist.

My current regex is:

((?:00|\+)
(?:9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)|\((?:00|\+)
(?:9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\))?
(?:(?:[-\.\s]??\d)|(?:[-\.\s]?\(?\d\)?)){4,11}

How can I fix it? I would be grateful for support.

EDIT Added a regex101 link with some test phone numbers and the regex https://regex101.com/r/lLuP1E/1

xyhlon
  • 95
  • 2
  • 9
  • [Does this help](https://stackoverflow.com/questions/2113908/what-regular-expression-will-match-valid-international-phone-numbers) – 0x263A Aug 31 '21 at 18:55
  • thx for the response. I used this site to some extend to create this regex because non of the regex i found where sufficient for matching weird phone numbers. Sadly this site does not contain the answer i am looking for. – xyhlon Aug 31 '21 at 19:10

1 Answers1

-1

this code will remove + and country code from groups:

[\+]..(.*)