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!

% Match string to string on X chars by x chars

user11440683Feb 22 2017 — edited Feb 23 2017

Hi,

A number of database versions back I developed a function to check one string against another string, moving through the string X characters, at a time and looking for a match in the other string (the characters are in the other string in the same order, with nothing between).

i.e.

String 1 'ABCDE' - the string to compare

String 2 'ABDEF' - the string to compare to

The number of characters to compare 2

So first two characters of string 1 - 'AB' - does it match to string 2 - yes - so 1 match

So move along one, and try again, next two characters of string1 - 'BC' - does it match to string 2 - no, so no match

So move along one, and try again, next two characters of string1 - 'CD' - does it match to string 2 - no, so no match

So move along one, and try again, next two characters of string1 - 'DE' - does it match to string 2 - yes, so +1 match

So out of 4 potential matches we have 2 hits, so using 2 character match this is a 50% score

In my original scenario, string 1, string 2 and the number of characters were all IN parameters, the function returning a number 0 to 100.

My question is, for purposes of speed I need to achieve similar match functionality on a massive data set and do not want to do this by a function, is there anyway using regex or similar existing database functions to achieve the same functionality??

My DB is 12c

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 22 2017
Added on Feb 22 2017
16 comments
727 views