Re: Regular Expression for a UK Mobile

From: Date: Fri, 15 Oct 2004 12:26:17 +0000
Subject: Re: Regular Expression for a UK Mobile
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-199580@lists.php.net to get a copy of this message
Shaun wrote:
Hi, Could anyone help me with a reugular expression for a UK mobile phone number? So far I have tried this but with no success <snip> $regexp = "/^447[0-9]{9}$/"; if(!preg_match( $regexp, $_POST[mobile_number] )){
     $error = "Invalid Mobile Number";
</snip> The number nust be 11 numbers long, be all numbers, have no spaces and begin with 447.
You're matching 447, then 9 numbers after that...bringing the total numbers to 12, not 11. $regexp = "/^447\d{8}$/"; -- By-Tor.com It's all about the Rush http://www.by-tor.com

« previous php.general (#199580) next »