Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why this regular expression does not match as expected?

sblandin1973Feb 20 2014 — edited Feb 20 2014

I am sorry I don't even know if this is the proper section to ask this question.

I have obtained a regular expression that tests if a string matches the representation of an octal number between 0 and 77776.

The regex is as follow:

^([0-7]{0,4}|[0-7]{4}(?(?<=^7777)[0-6]|[0-7]))$

I have tested it both inside an xsd pattern restriction and with a .NET System.Text.RegularExpression.RegEx object and the expression seems to work fine. It also work fine in Perl

Hovever if I write something like:

SELECT 1

FROM DUAL

WHERE REGEXP_LIKE('77777', '^([0-7]{0,4}|[0-7]{4}(?(?<=^7777)[0-6]|[0-7]))$');

The expression wrongly matches: 77777 should be out of the "allowed range" (it is not a real range, just a textual representation of it anyway)

Anyone knows how to rewrite the expression in order to make '77777' not matching?

This post has been answered by Frank Kulash on Feb 20 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 20 2014
Added on Feb 20 2014
12 comments
928 views