I have to validate a string against some rule. They are:
- Input can have optional hyphens but 3 hyphens at maximum.
- Hyphens should not be counted in length.
- The length should be exactly 14 digits.
- The string has to be numeric.
- The string shouldn't contain more than 5 continuous repetitive digits.
My regular expression which is working as expected in Java is
^(?!.*?(\\d)\\1{5})(?=(?:[0-9]-?){14}$)[0-9]+(?:-[0-9]+){0,3}$
I am trying to implement the same logic in the oracle script like below
IF(REGEXP_LIKE(<myInput>,'(?=(?:[0-9]-?){14}$)')
AND NOT REGEXP_LIKE(<myInput>,'([0-9])(\1){5}')
AND REGEXP_LIKE(<myInput>,'^[0-9]+(?:-[0-9]+){0,3}$'))
THEN ....
END IF;
Regular Expression to identify more than 5 continuous repetitive digits is working properly but (?=(?:[0-9]-?){14}$) and ^[0-9]+(?:-[0-9]+){0,3}$ are not working as expected.
Am I missing anything here? I tried to keep/remove brackets,start-line, and end-line anchors around the expressions but no luck.