php - managing the phone number validation exploits using regex -
I've written regex to validate the US and UK phone numbers. It's working fine, but not for all cases.
As such, it should not filter a valid number: Here is a list of all UK area codes: the big list Do I need to include them all? Regex? Problem: It should filter out such exploits: 203453seven67 How can this be done? Here is an example: Reject: To ensure that the phone number is correct, do not use regex and Use some standard libraries that can help you with phone number verification. I recommend 12345678 or
123456789 ,
1989 etc. Maybe I need to validate each one for the first three digits, is the area code of
US UK right?
$ pattern = '((^ \ (? (? :(?: 0 (?: 0 | 11) \) what's that? [\ S -] \ | 44 \) [\ s -] \ [\ s -] \? (\ +?)? ((?: 0 \?)? (?) | | 0) (?: \ D {2} \) [\ s -] \ d {4} [\ s -] \ d {4} | ?? \ d {3} \) [\ s -] \ D {3} ?? [\ s -] \ d {3,4} | \ d {4} \) [\ s -] (??? \ d {5} | \ d {3} [\ s - ] \ D ?? {3}) | \ d {5} \) [\ s -] \ d {4,5} | 8 (? 00 [\s -] 11 [45] [\? - - 46] x | ext \ \ s | \ #)? \ d +)) $) | ([[[2- 9] [0-8] [0- 9] \)? [-]] [0- 9] {3} [-]] [0- 9] {4})) ' ;
Comments
Post a Comment