> > Your subject says regex, but your request says Hpricot: > > > > require 'hpricot' > > doc = Hpricot(input) > > scripts = (doc/'script').map {|x| x['src']}.compact > > Ahh, that looks beautiful right there! But will hpricot work on > a .rhtml file? Probably - Hpricot should treat all the rhtml guff as if you're just really really bad at writing html and treat the rhtml bits as just raw. Hpricot('<%= <script src="monkey"> %>').at('script')['src'] => "monkey" The rhtml will get in the way of Hpricot seeing your tree correctly, so finding script tags only within the head section or something like that might not work, but for simple finds it should be fine. Dan.