To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 15 October 2004 12:39, 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}$/";

That expression looks perfectly valid for the conditions you have stated
(given that you meant 12 digits, not 11, which would be correct for UK
mobiles).  There must be some other kind of error.

As a first step, I suggest you do a var_dump($_POST['mobile_number']) to
make sure it's exactly what you think it should be.  (And, yes, you should
be quoting the index to the $_POST[] array.)

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

However, if you mean genuine mobiles, and not pagers or other follow-me type
numbers in the UK 07 range (or even completely unallocated parts of it!),
then you need to refine that pattern a bit; this should do:

   $regexp = "/^447[7-9][0-9]{8}$/";

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to