Re: phone number regular expression problem
- From: "Jürgen Exner" <jurgenex@xxxxxxxxxxx>
- Date: Wed, 31 May 2006 13:39:16 GMT
venu wrote:
I have a different requirement and it is :
I need to validate a phone number field.
It may or may not be a US phone number.
The constraints are :
***********************
# It should accept any number of numbers
# any number of - hyphens
# and one + symbol
# no other characters and alphabets are allowed
No need to wield the big RE gun.
Step 1: use tr() with the 'c' and 'd' options to keep only desirable
characters in the string. If the string has changed, then you know it
contained at least one unwanted character.
Step 2: see FAQ entry "How can I count the number of occurrences of a
substring within a string?" for counting the number of '+' symbols. If it's
more than one then you got an illegal entry.
jue
.
- References:
- phone number regular expression problem
- From: venu
- phone number regular expression problem
- Prev by Date: Re: phone number regular expression problem
- Next by Date: Re: phone number regular expression problem
- Previous by thread: Re: phone number regular expression problem
- Next by thread: Re: phone number regular expression problem
- Index(es):
Relevant Pages
|