Phone Number - Regular Expression
4610Dec 13 2007 — edited Dec 13 2007I'm trying to validate a phone number using regular expressions.
My validation appears as the following:
IF REGEXP_LIKE ( :P10_PHONE, '^\(?[[:digit:]]{3}\)?[-. ]?[[:digit:]]{3}[-. ]?[[:digit:]]{4}$' ) THEN
RETURN TRUE;
ELSE
RETURN FALSE;
END IF;
The problem I noticed is that it returned true even if I typed in a phone number like this:
(555 123-4567
Is there a way to tell it that if one parenthesis is there that the other one should be there as well? Or should I just do an instr if the regexp_like returns true and double-check it myself?
Thanks,
Chad