0

How to validating Phone numbers using Regx method. The problem is I want to Validate different formats of Phone numbers.I had Noted down the formats also. 1.XXXXXXXXXX 2.XXXX-XXX-XXX 3.XXXX-XX-XX-XX 4.XXXX:XXX:XXX 5.XXXX XXX XXX How to achieve this.Please suggest me.

Thanks in Advanced.

SaiRam
  • 13
  • 4

2 Answers2

1

Can be the Best way replace all the non-digit char

1.XXXXXXXXXX 2.XXXX-XXX-XXX 3.XXXX-XX-XX-XX 4.XXXX:XXX:XXX 5.XXXX XXX XXX 

like

1.XXXXXXXXXX 2.XXXXXXXXXX 3.XXXXXXXXXX 4.XXXXXXXXXX 5.XXXXXXXXXX 

and then reformat it. like

  1 (234) 567-8912
  1 (234) 567-8923 x4567

and On SO also there is number of Question related this

Buntylm
  • 7,345
  • 1
  • 31
  • 51
0

I use this library for my phone number validations.

https://github.com/me2day/libPhoneNumber-iOS

Google wrote a great library and these guys ported it to Objective-C. More robust than I needed, it's good stuff

Janene Pappas
  • 1,366
  • 12
  • 26