From: 7stud -- Date: 2011-08-23T08:56:53+09:00 Subject: Re: Regex find everything between > if tag.match(/class=\\"(.*?)editor(.*?)\\"/) # tries to match anything > with a class="editor" tag = '
' if tag.match(/class=\\"(.*?)editor(.*?)\\"/) puts 'yes' else puts 'no' end --output:-- no tag = '
' if tag.match(/class="(.*?)editor(.*?)"/) puts 'yes' else puts 'no' end --output:-- yes > close = get_closing_tag(tag) > > but /#{tag}(.+)#{close}]/ returns nothing Do you really expect anyone to be able to tell you what's wrong there? How would anyone know what get_closing_tag() returns? require 'nokogiri' f = File.open('html.htm') doc = Nokogiri::HTML(f) results = doc.xpath('//*[contains(@class,"editor")]').each do |el| p [ el.attributes['class'].value, el.children[0].text ] end --output:-- ["editor_greeting", "Hello world"] ["myeditor_fruit", "Apple"] ["editor_name", "Papillon"] ==== html.htm: Test

Hello world

Apple
Not this node.
Papillon
=== See the following for the basics of xpath: http://www.w3schools.com/xpath/default.asp -- Posted via http://www.ruby-forum.com/.