tags:

views:

27

answers:

1

Hi,

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 anyone 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.

A: 

You need to use regular expressions. This link pertains to python, but you can use these patterns by calling the PHP functions: http://diveintopython.org/regular_expressions/phone_numbers.html

http://php.net/manual/en/book.pcre.php

Matt Williamson