How to extract two strings difference
-
wrote on 14 Aug 2022, 01:05 last edited by
OK, I can RTFM but there are way too many options.
I am asking if somebody in this forum "been there, done that " - preferably in C/C++.I am NOT looking for comparing strings - I need to extract the actual difference between them .
How about "finding sub-string in string " and return what is left over or use regular expression.
Would iterating thru both strings and returning "no match" work?
I am asking for ideas -
wrote on 14 Aug 2022, 01:59 last edited by
OK, I can RTFM but there are way too many options.
groan
I am NOT looking for comparing strings - I need to extract the actual difference between them .
Please define "difference" without comparing strings.
-
wrote on 15 Aug 2022, 21:20 last edited by
std::string::find()
std::string::erase() -
What constitutes a difference in your case? What result would you expect when comparing "Hello world" with "The answer is 42"? Do you mean compare on word or letter basis? Is whitespace important? What about strings of different lengths? Do you want a list of different strings or offsets into either of the string as a result?
You need to be a lot more specific for any useful suggestions. A real life example with input strings and expected result would be best.
-
std::string::find()
std::string::erase()wrote on 17 Aug 2022, 19:23 last edited by@Kent-Dorfman Brilliant , simply brilliant. Thanks
1/5