Question:
Prompt a regular expression to find a cell phone number in the text.
Phone numbers are entered by different users and in a completely unpredictable format, for example, – + () _ spaces can participate and it is not yet known what the imagination will be enough for.
Examples of phones:
8 900 000-00-00
+7 (900) 000 00-00
+7 9001112233
89001112233
8 (900) 111-2233
etc
Answer:
As an option:
/(?:\+|\d)[\d\-\(\) ]{9,}\d/g
- Starts with: "+" or a number
- Then it may contain: numbers, "-", "(", ")", space. Repeating 9 or more times
- Ends with a digit
https://regex101.com/r/poJz8C/5