Regular expressions problem

Hi all,

I created a regex for matching mobile number …

$search = preg_match_all(“~(\d{1,}\s?|\d?\s?\(\d{1,}\)|\d{1,}-)?\s{0,}\d{1,}[.\s]?/?[.\-]?[.\s\-\s]?\d{1,}[.\s]?\d{1,}[.\s]?[.\-]?[.\s\-\s]?\d{1,}~”,$text,$matches);

It works fine with most phone numbers, but sometimes it doesn’t work …
This is a sample of a working number : + 2 010 5646024
and this is a sample of a not working number : + 2 385 230 61
I don’t understand why the second number + 2 385 230 61 is not matched …
N.B When I add any integer to the second number , it works , eg + 2 385 230 611

So how can I edit my regex to match the second number?

Regards,

How do you define a mobile number for your country?

It’s not important for that…
But only I want to edit the code to match also this number + 2 385 230 611

Why not just keep it simpler, allowing a certain number of digits (say 12 or so), + and spaces?

How to do so ?
I’m pretty new to using regular expressions

Me too. :smiley:

Perhaps something like this? (Replace $phone with your own variable.)

preg_match("/^[0-9\\s\\+]{8,16}$/", $phone)