ruby如何取html代码中的img标签

ruby怎么取html代码中的img标签##取html代码中的第一张图片def get_picconif self.content!nilself.co

ruby怎么取html代码中的img标签
##取html代码中的第一张图片
  def get_pic
    con=""
    if self.content!=nil
      self.content=self.content.force_encoding('utf-8')
      con=/(<img).+(src="?.+)\/(.+\.(jpg|gif|bmp|bnp|png)"?).+>/.match(self.content)
      con=con.to_s.split("/>")[0]+"/>"
      return con.html_safe
    else
      return ""
    end
  end