0

I need idea about logic which will match repeated character sets comparing two strings.

Car is blue and new vs Car is blue and old, would find 16 matches Car is , blue vs Car is blue color would find Car is match and blue

So basically I need to find percentually how much repeating characters are the same in two strings, SQL Server or C#, preferably SQL server.

I don't expect someone to write me code, but any idea, link or something like that would be more than welcome.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
xyz
  • 21
  • 1
  • 2

3 Answers3

0

Little idea here, you could get a list of all the words in one string, and then check if they exist in the other string:

string baseStringOne = "Car is blue and new", baseStringTwo = "Car is blue and old"; 
string[] subs = baseStringOne.Split(' '); 
foreach (string sub in subs)
{
  if (baseStringTwo.Contains(sub))
  {
     //Substring found!
  }
}
Zukki
  • 36
  • 5
0

I think you'll find these relevant:
The diff algorithm
An implementation for C#

Artless
  • 4,522
  • 1
  • 25
  • 40
0

You can get distinct characters by :

public static string Common(string s1, string s2)
    {
        return new string((s1.Intersect(s2)).ToArray());
    }
NG.
  • 5,695
  • 2
  • 19
  • 30