Created
August 1, 2010 19:44
-
-
Save johnnygoodman/503682 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'differ' | |
# Question: Is there a way to say match 1 or more instances of a defined subsequence/grouping? | |
original = "Epic lolcat fail bellmead drive!" | |
current = "Epic wolfman fail bellmead dr!" | |
diff = Differ.diff_by_word(current, original).to_s | |
puts diff # => "Epic {"lolcat" >> "wolfman"} fail bellmead {"drive" >> "dr"}! | |
diff =~ /(\{"[a-zA-Z0-9]*" >> "[a-zA-Z0-9s]*"\})/ | |
puts "#{$1} to #{$2} #{$3} to #{$4}" | |
# => lolcat to wolfman to | |
# Desired output: lolcat to wolfman to drive to dr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment