What you are trying to do is finding the percentage of similarity of two strings.
Some algorithm out there already solve this exact same problem.
I been using mainly:
- LevenshteinDistance
- NGramDistance
I had a quick search in delphi for the code source.
I found the source code for Lenvenshtein in delphi
Lenvenshtein algorith is trying to find in "how many change" it can rollback to the original string.
NGramDistance is comparing the words by splitting them.
So with Lenvenshtein the string
"abc def | klm mno" will be see as very different than "klm mn | abc def"
But NGramDistance will see them as 100% similar.
So it depend if you want the order of the string into account.
I couldn't find any source code for the NGramDistance. But you can translate it from Java to Delpi.
The source code in java come from Lucene, an open source search software. They implemented lot more String metric algorithms checkout in this package