How to find the diffrence between two strings?

I.e taking one string as base string and finding the missing or extra elements which are present in another string?

        string s1 = "i have a car a car";
        string s2 = "i have a new car bmw";

        List<string> diff;
        IEnumerable<string> set1 = s1.Split(' ').Distinct();
        IEnumerable<string> set2 = s2.Split(' ').Distinct();

        if (set2.Count() > set1.Count())
        {
            diff = set2.Except(set1).ToList();
        }
        else
        {
            diff = set1.Except(set2).ToList();
        }

Output of this code will be new, bmw

2 Likes

using UiPath for strings more than 256 characters minimum?

Can you explain with a sample how you want to see the result.

got it

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.