0

I have having little trouble getting the required match.

string1 ="lanet fit/club fees 123-456-7150 1935006123456 abcd avcbfg"
string2 ="ABC*lanet Fitness       308-3207001  NX"

regex=^(.*)([(]?[0-9]{3}[)]?[-.\s][0-9]{3}[-.\s]?[0-9]{4})(.*)$

also can be checked here. regexr.com/5ahru

I need group 2 as the phone number 123-456-7150and 308-3207001 but i am getting 150 1935006 as group 2 for string1.

Any thing which needs to be corrected?

ben
  • 1,404
  • 8
  • 25
  • 43

0 Answers0