Skip to content

Instantly share code, notes, and snippets.

Created May 20, 2013 03:01
Show Gist options
  • Save anonymous/5610197 to your computer and use it in GitHub Desktop.
Save anonymous/5610197 to your computer and use it in GitHub Desktop.
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")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment