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!

regular expression to check a value if it contains a specific word.

Amer Ramamni-OracleOct 17 2012 — edited Oct 17 2012
Hi All,

How can i check if a certain word exists in a value in regular expression ?
I have an attribute called Race. Race can contain the following:

White, Non-Hispanic
Black, Non-Hispanic
White, Non Hispanic
Black, Non Hispanic
White, NonHispanic
Non-Hispanic, white
Non Hispanic - black

What i want is to check if my value contains the word "NON" (NON can be at the beginning, middle or end), if it does, parse it and return it.

This is what I have, however I want to make sure it covers all cases and not missing anything else
select REGEXP_SUBSTR(UPPER(trim('Black, Non-Hispanic')), '[NON]+') from dual;
Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 14 2012
Added on Oct 17 2012
7 comments
557 views