Filter phone numbers out of message
I'd like to filter phone numbers out of the users message. The problem is ofcourse that a phone number can be written in different ways. Like:
0612345678 06 123 45 678 +31 (0)612345678 +31 (0)6 12 34 56 78
But I've got absolutely no clue how to do this and I'm pritty stuck. Can a开发者_StackOverflow中文版nyone help me a bit?
Thanks!
Edit: In the meanwhile I came with this regular expression: "/(\d|\s){5,}/im". This filters every number of at least 5 characters and ignores the spaces. That way, all numbers from my previous example will be filtered.
You need to use regular expressions. This link pertains to python, but you can use these patterns by calling the PHP functions: http://diveintopython3.ep.io/regular-expressions.html#phonenumbers
http://php.net/manual/en/book.pcre.php
精彩评论