Thanks Walter, ended up with this:

doc = Nokogiri::HTML.parse(File.new(merge_path))
nodes = doc.xpath("//text()[contains(.,'MERGE')]")
nodes.each do |node|
  text = node.text
  if md = text.match(/.{2}MERGE(\d+).{2}/)
    start_index = text.index(md[0])
    start_span_tag = "<span id='merge_#{md[1]}'>"
    end_index = start_index + start_span_tag.length + md[0].length
    node.content = text.insert(start_index, 
start_span_tag).insert(end_index, '</span>')
  end
end

Works great.

Wes

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to