How to make a NON-LINE based diff between two strings in Java
Posted
by Mycol
on Stack Overflow
See other posts from Stack Overflow
or by Mycol
Published on 2010-05-19T11:41:57Z
Indexed on
2010/05/19
13:30 UTC
Read the original article
Hit count: 255
diff
I have to compare the text content of two xml elements, eg.
<p>During lunch he hears strangers whispering, catching the name "Potter" and "Harry", and someone saying You-Know-Who has gone at last. </p>
and
<p>During dinner he hears strangers whispering, catching the name "Rossi" and "Mario", and someone saying You-Know-Who has gone at first. </p>
What I'm looking for is some java libraries to make a diff between the content of paragraphs. All the tools I found makes a line diff. But they're not what I want, simply because i have no lines, but "strings" to compare. What I need is to have a char-based diff: eg. a diff that tells me something like " from the first file, remove char from 8 to 12, add the string "dinner" from char 8."
© Stack Overflow or respective owner