websss
asked on
regular expression - 4 OR 6 digits
Hi
I need a regular expression to validate the user input
it has to be numeric
and it has to be either 4 or 6 digits
i'm not bothered about someone entering all zeros
I need a regular expression to validate the user input
it has to be numeric
and it has to be either 4 or 6 digits
i'm not bothered about someone entering all zeros
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
^[0-9]{4,6}$
OR
/^\d{4|6}$/
would do the work
OR
/^\d{4|6}$/
would do the work
ASKER
^[0-9]{4,6}$ allows 5 digits
it needst to be 4 OR 6
it needst to be 4 OR 6
ASKER
i had a trailing space.... it worked!
I hope there would have been slight change in comment
^[0-9]{4,7}$
and it would have worked right ?
^[0-9]{4,7}$
and it would have worked right ?
ASKER