Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Gareth Williams
You could add is_integer() into the if statement. On 15 Oct 2004, at 14:07, Robert Cummings wrote: On Fri, 2004-10-15 at 07:45, Gareth Williams wrote: Do you even need a regex? What about if (strlen($_POST['mobile_number']) != 11 && substr($_POST['mobile_number'],0,3) != 447) { $error="Inva

Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Chris Dowell
Try is_int($_POST['mobile_number']) or ctype_digit($_POST['mobile_number']) HTH Cheers Chris Robert Cummings wrote: On Fri, 2004-10-15 at 07:45, Gareth Williams wrote: Do you even need a regex? What about if (strlen($_POST['mobile_number']) != 11 && substr($_POST['mobile_number'],0,3) != 447) { $

RE: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Ford, Mike
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

Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread John Nichel
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 $regexp = "/^447[0-9]{9}$/"; if(!preg_match( $regexp, $_POST[mobile_number] )){ $error = "Invalid Mobile Number"; The number nust be 11 numbers long,

Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Jason Wong
On Friday 15 October 2004 19:38, Shaun wrote: > Could anyone help me with a reugular expression for a UK mobile phone > number? > > So far I have tried this but with no success > > > $regexp = "/^447[0-9]{9}$/"; > if(!preg_match( $regexp, $_POST[mobile_number] )){ > $error = "Invalid Mobile

Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Robert Cummings
On Fri, 2004-10-15 at 07:45, Gareth Williams wrote: > Do you even need a regex? > > What about > > if (strlen($_POST['mobile_number']) != 11 && > substr($_POST['mobile_number'],0,3) != 447) > { > $error="Invalid Number"; > } This doesn't verify that the portion following 447 is also a num

Re: [PHP] Regular Expression for a UK Mobile

2004-10-15 Thread Gareth Williams
Do you even need a regex? What about if (strlen($_POST['mobile_number']) != 11 && substr($_POST['mobile_number'],0,3) != 447) { $error="Invalid Number"; } On 15 Oct 2004, at 13:38, Shaun wrote: Hi, Could anyone help me with a reugular expression for a UK mobile phone number? So far I have tried

Re: [PHP] Regular Expression for a UK mobile phone number

2004-04-08 Thread gohaku
On Apr 8, 2004, at 2:40 PM, Shaun wrote: Thanks for your reply Michal, but the regular expression still seems to reject the number... Just out of curiosity, Have you tried " if(stripslashes(htmlentities($_POST[mobile_number]) ) != ") ? -- PHP General Mailing List (http://www.php.net/) To unsubs

Re: [PHP] Regular Expression for a UK mobile phone number

2004-04-08 Thread Michal Migurski
>but the regular expression still seems to reject the number... Can you provide an example of numbers it rejects? My answer was based on the simple fact that you were testing for numbers that matched, and returning a rejection based on that. The regexp is simple enough -- some examples of input w

Re: [PHP] Regular Expression for a UK mobile phone number

2004-04-08 Thread Shaun
Thanks for your reply, but the number cannot be out side the UK or contain spaces, leading zeros, brackets or dashes "Jochem Maas" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > you should also be considering spaces, leading zeros, brackets, dashes & > international notation. > >

Re: [PHP] Regular Expression for a UK mobile phone number

2004-04-08 Thread Jochem Maas
you should also be considering spaces, leading zeros, brackets, dashes & international notation. /^(((\+|00)[- ]?[0-9]{2,3}[- ]?(\(0\))?[- ]?[1-9]{1}[0-9]{1,})|(0[1-9]{1}[0-9]{1,}))[- ]?(([0-9]{7,})|([0-9]{3}[ -]{1}[0-9]{4}))$/ line-wrapping is unintentional, no garantees as to how good it is.

Re: [PHP] Regular Expression for a UK mobile phone number

2004-04-08 Thread Shaun
"Michal Migurski" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > >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 num

Re: [PHP] Regular Expression for a UK mobile phone number

2004-04-08 Thread Michal Migurski
>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! Try this: $regexp = "/447[0-9]{9}/";