Hi I am using c# language in my project and I am trying to get output something like below.
string str1 = "Cat meet's a dog has";
string str2 = "Cat meet's a dog and a bird";
string[] str1Words = str1.ToLower().Split(' ');
string[] str2Words = str2.ToLower().Split(' ');
var uniqueWords = str2Words
.Except(str1Words)
.Concat(str1Words.Except(str2Words))
.ToList();
This gives me out put has,and ,a, bird which is correct but what i would like is something like below
has - present in first string not present in second string
and a bird - not present in first string but present in second string
For example, second user case
String S1 = "Added"
String S2 = "Edited"
here out put should be
Added - present in first string not present in second string
Edited - not present in first string but present in second string
I would like to have some indication which is present in first and not in second, present in second and not in first and comparison should be word by word rather than character by character. Can someone please help me with this. Any help would be appreciated. Thanks
I suggest matching words
with a help of regular expression (please, note that splitting doesn't take punctuation into account and thus
catcat,andcat!will be considered three different words) and then query matches for two given strings:Demo:
Output:
Fiddle
If you want a wordy output:
Output: