Skip to content

Instantly share code, notes, and snippets.

@johnnygoodman
Created August 1, 2010 22:00
Show Gist options
  • Save johnnygoodman/503814 to your computer and use it in GitHub Desktop.
Save johnnygoodman/503814 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'differ'
original = "Epic lolcat fail bellmead drive!"
current = "Epic wolfman fail bellmead dr!"
diff = Differ.diff_by_word(current, original).to_s
# => "Epic {"lolcat" >> "wolfman"} fail bellmead {"drive" >> "dr"}!
original = "Same Same diff Same Same diff Same Same diff"
current = "Same Same wooo Same Same wooo Same Same wooo"
# => "Same Same {"diff" >> "wooo"} Same Same {"diff" >> "wooo"} Same Same {"diff" >> "wooo"}"
=begin
I won't know how many diffs the strings will have until I run the script. I need to parse how ever many matches I have out of the result string. Each match is in the format: {"diff" >> "wooo"}. I need to write a regexp, split or combo that allows me to put each match into a key,value hash.
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment