Regular Expression for a UK mobile phone number
| From: | Shaun | Date: | Thu, 08 Apr 2004 16:41:03 +0000 |
| Subject: | Regular Expression for a UK mobile phone number | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-182863@lists.php.net to get a copy of this message | ||
Hi,
I am trying to create a regular expression for a mobile phone number. The
number must be 12 digits long(0-9) and begin with 447 and have no spaces. So
far I have come up with this but it keeps telling me the number is invalid
even when its correct!
$regexp = "/447[0-9]{9}/";
if($_POST[mobile_number] != ''){
if(preg_match( $regexp, $_POST[mobile_number] )){
$error = "Invalid Mobile Number";
header("Location:
edit_rep.php?error=$error&rep_id=".$_GET[rep_id]."&client_id=".$_GET[client_
id]."&rep_name=".$_GET[rep_name]."&client_name=".$_GET[client_name]."");
exit;
}
}
I would be most grateful for any advice offered.