Index independent character comparison within text blocks

Posted by Michael IV on Programmers See other posts from Programmers or by Michael IV
Published on 2013-03-02T17:48:54Z Indexed on 2013/06/28 16:30 UTC
Read the original article Hit count: 335

Filed under:
|

I have the following task: developing a program where there is a block of sample text which should be typed by user. Any typos the user does during the test are registered. Basically, I can compare each typed char with the sample char based on caret index position of the input, but there is one significant flaw in such a "naive" approach. If the user typed mistakenly more letters than a whole string has, or inserted more white spaces between the string than should be, then the rest of the comparisons will be wrong because of the index offsets added by the additional wrong insertions.

I have thought of designing some kind of parser where each string (or even a char ) is tokenized and the comparisons are made "char-wise" and not "index-wise," but that seems to me like an overkill for such a task. I would like to get a reference to possibly existing algorithms which can be helpful in solving this kind of problem.

© Programmers or respective owner

Related posts about c#

Related posts about strings