Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: string diff and compare

by raybies (Chaplain)
on May 07, 2012 at 13:48 UTC ( #969263=note: print w/replies, xml ) Need Help??

in reply to string diff and compare

So I found an interesting failure of this approach when I was trying out this on more data. It occurs when I have the following sort of data.

__DATA__ I am me. I am not me.

Essentially, I end up creating the following output.

I am<<span>/span> me. I am <span>not</span> me.

The problem is due to the fact that the space before the not (in "am not me"), and the space after the not are not the same space, but the matching can't tell that and because you search from the back of the string first, and then the front of the string, yet both are fine with the space between "am me." so the offsets are off by one.

fixing now... a quick solution is to arbitrarily add one to the negative index, but it's clearly imperfect, because when this isn't the case, it'll highlight (span) one extra matching character.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://969263]
[LanX]: On another node, I just saw yesterday that the everything engine supports auto-paragraph whithout the need to type <p>
LanX i.e. the newest everything engine
[holli]: nice. i never thought of hosting a script on the site
[LanX]: It's not a perfect solution, since it means invoking the monastery several times, but IMHO still better than hosting on another server
[holli]: i'm surprised it even executes. the server sends text/plain AND a content-dispositio n header
[holli]: this really really should not be executed as Javascript
erix's head is getting content indisposed

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2017-11-20 19:13 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (291 votes). Check out past polls.