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 matching all the given words

user1421762Nov 8 2012 — edited Nov 9 2012
I'm trying to match all sentences that contain words starting with given search tokens at least once. For example: if the given search token words are one and two then only sentences like "one plus one is two" should match. And should not match sentences like "one plus three is four". I was able to come up with this but I need a AND condition which I'm unable to get it right. Any help is appreciated.

select count(*) from dual where regexp_like('one plus one is two', '(^|\s)one|three', 'i');

Currently this gives a count of 1. But needs to give a count of 0 when the regexp is fixed.

search words : one two

one is less than two -> match
two is greater than one -> match
onetwo is union of two numbers -> match
onetwo is union of 2 numbers -> not a match as 'two' is not at the beginning of a word
one is less than three -> not a match as two is not present.

Thanks

Edited by: user1421762 on Nov 8, 2012 11:28 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 7 2012
Added on Nov 8 2012
7 comments
1,359 views