Skip to content

Instantly share code, notes, and snippets.

@netshade
Created April 27, 2010 19:37
Show Gist options
  • Save netshade/381195 to your computer and use it in GitHub Desktop.
Save netshade/381195 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
file_path = ARGV[0] || 'go4_global_sub_navigation.html'
raise "#{file_path} does not exist, please specify which file you want to alter the navgo4_t_* on" unless File.exists?(file_path)
contents = File.read(file_path)
contents.gsub!(/<a(.+?)href\s*=\s*(['"].+?\?)navgo4_t_(.+?)(['"][^>]*)>(.+?)<\/a>/i) { |match| "<a href=#{$1}navgo4_t_#{$4.downcase.split(" ").join("_")}#{$3}>#{$4}</a>" }
wr = File.new(file_path, "w+")
wr.write(contents)
wr.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment