使用正则表达式管理电话号码验证漏洞利用

I have written regex to validate the US and UK phone numbers. It is working fine but not for all case.

like it should not filter legitimate numbers like : 12345678 or 123456789, 1989 etc. Probably I need to validate each area code of US UK for first three digits. Am I right?

Here is the list of all UK area code: http://www.area-codes.org.uk/ big list. Do I need to include all of them in regex?

Issue: it should also filter exploits like this : 203453seven67

how it could be done?

Here is the example : http://ideone.com/zwzmKU

REgex:

$pattern = '((^\(?(?:(?:0(?:0|11)\)?[\s-]?\(?|\+)44\)?[\s-]?\(?(?:0\)?[\s-]?\(?)?|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[\s-]?11|45[\s-]?46[\s-]?4\d))(?:(?:[\s-]?(?:x|ext\.?\s?|\#)\d+)?)$)|(\(?[2-9][0-8][0-9]\)?[-. ]?[0-9]{3}[-. ]?[0-9]{4}))';

For making sure the phone number is correct, avoid using regex and use some standard library which can help you with the phone number validations.

I suggest https://code.google.com/p/libphonenumber/