Skip to content

Instantly share code, notes, and snippets.

Created May 20, 2013

What would you like to do?
answer to a question on ruby-talk
#regexes for find/replace
add_tabs = /^(term1)/
remove_tab = /\t(\tterm2)/
clear_stuff = /.*hat\.goat\sthis thing\sthat thing\sstuff\scheese/m
#read file and replace
puts "Paste in your input:"
while (line = gets)
next if $. == 1 .. line =~ clear_stuff
print line.gsub(add_tabs, "\t\t\\1").gsub(remove_tab, "\\1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.