开发者

Compare two versions of a text file and find additions/removals with Ruby? [duplicate]

This question already has answers here: diff a ruby string or array (12 answers) Closed 8 years ago.

I am tracking changes in a web-page using Ruby. After I removed all html tags and blank lines, I get an array of lines which needs to be checked for additions/removals assuming that there may be repetitions. Could you recommend a good gem if it has been done already?

I could make the array lines unique and then the problem is a开发者_如何学运维voided. But what if I need to track the repeated lines as well with respect to their position in the text?


Sounds like a textbook case of where you'd want to use the Diff algorithm.

There's a 'diff' gem, although to be fair I've never used it: http://rubygems.org/gems/diff

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜