How to validate zipcode using regular expression?
It should be in the following pattern:-
[A-z][0-9][A-Z] [0-9][A-Z][0-9]
E.g.
B5D 2M4
b5d 2m4
I am using Oracle9i.
Thanks in advance,
Shubhojwal Ghosh
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately, since you are using a very old version of Oracle, you cannot use the standard regular expression functions like
REGEXP_LIKE. If you were to upgrade to a moderately recent version of Oracle, that would be the way to go.In older versions of Oracle, you would have to use the
OWA_PATTERNpackage. Note that since theOWA_PATTERN.MATCHfunction returns aBOOLEAN, you cannot call it from SQL, just from PL/SQL. You could, of course, create your own wrapper function that returns an integer or a string to indicate whether the ZIP code is valid.