2

How can I find common substrings of two strings in order to show changes/edit of a string?

So what I try to do is to compare an old version of a string:

string_old = "My name is pm730! How are you?"

with a new/edited version of the string:

string_new = "My name isn't pm730, it is pm740!"

Deleted substrings are not important. New substrings should be distinguished somehow, so that I could output it like this eventually:

My name isn't pm730 , it is pm740!

This task sounds easy but is more complicated than I thought. So my hope is that there is already an similar implementation available, but unfortunanly I can't find it...

5
  • 3
    What you have tried by yourself so far?
    – ParthS007
    Commented Aug 19, 2021 at 9:10
  • 2
    Are you asking how you can find common substrings or how to display bold text?
    – mkrieger1
    Commented Aug 19, 2021 at 9:11
  • @mkrieger1 How to find common substings but bound on their location in order to eventually do somthing like the bold text. But the bold text isn't part of the question.
    – Pm740
    Commented Aug 19, 2021 at 9:12
  • @ParthS007 I've already found all common substrings. I'm stuck on the part with the position bounding of the substrings.
    – Pm740
    Commented Aug 19, 2021 at 9:18
  • Have you seen stackoverflow.com/questions/17904097/…?
    – mkrieger1
    Commented Aug 19, 2021 at 9:19

0

Browse other questions tagged or ask your own question.