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!

REGEXP_LIKE help

dvsoukupJul 26 2012 — edited Jul 26 2012
Hello,

Been scouring the web looking for some help using the REGEXP_LIKE syntax. Haven't found a precise answer, but I think I wrote my own correctly and just wanted to get some validation from other users.


Running Oracle 10.2

Sample Data:
create table test(data varchar2(10));
    insert into test values('01W00012');
    insert into test values('50321070');
    insert into test values('A1391010');
    insert into test values('ZZ260010');
    insert into test values('29374C01');
    insert into test values('A938523A');
    insert into test values('23W48AC3');
    insert into test values('DKFUGHCK');
    insert into test values('09W00032');
    insert into test values('94857283');
    insert into test values('AB-29348');
    insert into test values('98W-8923');
    insert into test values('0AW00005');
    insert into test values('04300W05');
    commit;
What I'm trying to do:
I have a table containing millions of work orders. They are all of length 8. I want to find all work orders where the first 2 characters are a digit only, the third character is a 'W', and the last 5 characters are digits only. Anything else I want to throw away. I think I came up with a working expression... but I'm always hesitant when running it against millions of rows. Here was what I did:
select * from test
    where regexp_like(data, '(^[0-9]{2}W{1}[[:digit:]]{5})');
There are exactly 2 occurrences from up above that match the criteria I'm trying to meet.
Is this expression properly written?

Any help would be greatly appreciated.... reg expressions always make my head spin :(
This post has been answered by Frank Kulash on Jul 26 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2012
Added on Jul 26 2012
6 comments
588 views