as per the specification
phone number should be
Alhpa-Numeric,
Space allowed,
hypen allowed,
bracket allowed,
max length = 45
can be null as well.
below is what i made using my limited knowledge and examples but its giving
error : Compilation failed: nothing to repeat at offset 29
My PHONE regex =
define('PHONE','#([a-zA-Z0-9][\s\(\)\-])*{0,45}#i');
please guide what should i do to have all the above specification matched using regex.
thanks
The regex won’t match what you want, with
([a-zA-Z0-9][\s\(\)\-])each number must be followed by a space, parentheses or hyphen. to fix that make[\s\(\)\-]optional:([a-zA-Z0-9][\s\(\)\-]?)and use preg_match.