All pastes #949997 Raw Edit

Miscellany

public text v1 · immutable
·published 2008-03-20 07:27 UTC
rendered paste body
  def remove_tag(s, tag)
    return s.to_s.gsub("<#{tag}\b[^>]*>(.*?)</#{tag}>", '\1')
  end
# I want to be able to:
# remove_tag("<input name="something">hrm...</input>", "input") => "hrm..."

# try this:
def remove_tag(s, tag)
  s.to_s.match(/<#{tag}\b[^>]*>(.*?)<\/#{tag}>/)[1]
end