-2

I need a regex to extract a phone number from a string in the format (99) 9999-99999 or (99) 99999-9999, tested some more no work out, need it in Delphi using "System.RegularExpressions"

not work

(\(11\) [9][0-9]{4}-[0-9]{4})|(\(1[2-9]\) [5-9][0-9]{3}-[0-9]{4})|(\([2-9][1-9]\) [5-9][0-9]{3}-[0-9]{4})

not work

(?:(?([0-9]{2}))?[-. ]?)?([0-9]{4})[-. ]?([0-9]{4})

Ps: I not found in any search that works exactly.

Jason-X
  • 39
  • 2
  • 11

1 Answers1

1

Try this pattern:

\(\d{2}\)\s(\d{4}-\d{5}|\d{5}-\d{4}|\d{4}-\d{4})

https://regex101.com/r/zF2cH0/2

coffee-converter
  • 967
  • 4
  • 13