[Solved] How to find words that are different between two Strings? [closed]


if it’s only words you can split the strings to string[] that each cell will contain 1 word only and then compare those words. Goes as follows:

String one = "this is first text example";
String two = "this is next text example";
String[] oneVals = one.split("\\ ");
String[] twoVals = two.split("\\ ");
int i = oneVals.length;
if(oneVals.length != twoVals.length)
{
    // determine what to do
}
String wordsNotMatching = "";
for(int j=0; j<i; j++)
{
    if((!oneVals[j].equals(twoVals[j])))
        wordsNotMatching += oneVals[j] + " ";
}
// wordNotMatching will contain all different words.

0

solved How to find words that are different between two Strings? [closed]