0

I have an initial string which will be changed and I want to know how many new characters were added (even when others are removed).

For exemple:

Initial string ==> "I love Programming so much"
Changed string ==> "I used to love programming"


Changes:


"used to " 8 chars added
" so much" 8 chars deleted

The result I want is the number of added chars which is 8.

Can anyone help me please?

T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875

1 Answers1

7

The number of characters you have to change to get from one string to another is called the Levenshtein distance, sounds like that might be what you want. You can find some JS implementations here.

Jotha
  • 418
  • 2
  • 7