Skip to content

Instantly share code, notes, and snippets.

@david-hodgetts
Created January 29, 2012 21:43
Show Gist options
  • Save david-hodgetts/1700848 to your computer and use it in GitHub Desktop.
Save david-hodgetts/1700848 to your computer and use it in GitHub Desktop.
convert tags for nicolas
# variables
input_filename = 'in.html'
output_filename = 'result.htm'
#
def convert_line(line)
regex = /(TAGS=".*")/
line.gsub(regex) { $1.gsub(/\s+/, ',') }
end
#
out_file = File.open(output_filename, 'w+')
File.open(input_filename, 'r') do |in_file|
while line = in_file.gets
out_file.puts(convert_line(line))
end
end
out_file.close
@david-hodgetts
Copy link
Author

Simple ruby script to replace spaces by commas in following type of strings -> 'TAGS="DropBox tips mustcheck"'
for nicolas.
Usage:
copy file to the directory with the file you want to parse.
Open a terminal and cd to that directory
in the ruby file change 'input_filename' to be the name of the target file (do not remove the quotes)
in the ruby file change 'output_filename' to be the name of the new file.
in the terminal type "ruby convert_tags.rb"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment