How to retrieve the text difference between two strings having substrings
I got requirement to find the difference between two strings and write the difference to new file by comparing the substrings separted by commas
Below mentioned is an example of requirement
String1 --> ABC,DEF,GHI,JKL
String2 --> MNO,ABC,XYZ,DEF
In String1 and String2 the substrings are separted by commas. The substrings which are common between String1 and String2 are ABC,DEF this common substrings has to be written to a file say common.txt ( having the text ABC,DEF). And the substrings GHI,JKL in String1 which are not present in String2 has to be written to another file say String1Extra.txt (having the text GHI,JKL). In the same way the substrings MNO,XYZ from String2 which are not present in String1 has to be written to another file say String2Extras.txt(having the text MNO,XYZ) .
How to achieve this ?
Many thanks in advance for your help