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}/;
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}/;
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
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.
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.
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
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
7 matches
Mail list logo