I have a PL/SQL funtion where I validate a field value using Regex.Below is the if statement I have in the PL/SQL function. where Im trying to verify if the Input is alphanumeric with atleast one number and one alphabet
if(regexp_like('AB67868777','^(?=.*[0-9])(?=.*[A-Z])([A-Z0-9]{10}+)$')
When the execution reaches the above line, It returns false instead of true. I have verified the regex and it works fine. Have used an online java regular expression validator and tested the above regex script and input param. The result was true. Where as when executing it from the code it returns fall.
Need some inputs to identify why the if statement above in the PL/SQL function is returning false
Help Required
Any help on this is much appreciated.
In Oracle, look-ahead (and look-behind) are not supported in regular expressions. You can get the same effect by using REGEXP_LIKE
for each separate test:
if(
regexp_like('AB67868777','^[A-Z0-9]{10}+$')
and regexp_like('AB67868777','[0-9]')
and regexp_like('AB67868777','[A-Z]')
)