Skip to content

Instantly share code, notes, and snippets.

@trcook
Created April 3, 2013 13:58
Show Gist options
  • Select an option

  • Save trcook/5301416 to your computer and use it in GitHub Desktop.

Select an option

Save trcook/5301416 to your computer and use it in GitHub Desktop.
regex hash
my_input=File.open("my_input.txt","r") # load some file as type: File
fixb=Hash.new
fixb.merge! "\t" => "&",
"\n"=>"\\\\"+"\\\\"+"\n",
"\""=>""
my_output=my_input.read.to_s
fixb.each_pair do |key, val|
my_output.gsub!(key,val)
end
IO.write('my_file_out.tex', my_output ) # Writes the file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment