Skip to content

Instantly share code, notes, and snippets.

@leandro
Created March 19, 2009 08:24
Show Gist options
  • Save leandro/81647 to your computer and use it in GitHub Desktop.
Save leandro/81647 to your computer and use it in GitHub Desktop.
module RIndexer
RE_TAG = %r!<([a-z\d_-]+)\s*.*?>!im
def fetch_tags(doc_stream)
tags = Hash.new(0)
doc_stream.scan(RE_TAG).each do |e|
tags[e] += 1
end
tags
end
end
include RIndexer
arg = ARGV.shift
p fetch_tags(IO.read(arg))
#USAGE: ruby teste.rb document.xml (or html, etc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment