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.
>
> /^(((\+|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.
>
> Shaun wrote:
>
> > "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 number is
> >>>invalid even when its correct!
> >>
> >>Try this:
> >>
> >>$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_i
> >
d=".$_GET[client_id]."&rep_name=".$_GET[rep_name]."&client_name=".$_GET[clie
> > nt_name]."");
> >
> >>     exit;
> >>  }
> >>}
> >>
> >>Also, your regexp is a little permissive; you can anchor it like so:
> >>
> >>$regexp = "/^447[0-9]{9}$/";
> >>
> >>---------------------------------------------------------------------
> >>michal migurski- contact info and pgp key:
> >>sf/ca            http://mike.teczno.com/contact.html
> >
> >
> > Thanks for your reply Michal,
> >
> > but the regular expression still seems to reject the number...
> >

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

Reply via email to