All pastes #30330 Raw Edit

epimaas

public ruby v1 · immutable
#30330 ·published 2005-11-22 19:01 UTC
rendered paste body
def unescapeHTML(string)  str = string.dup  str.gsub!(/&(.*?);/n) {    # block that returns the replacement    match = $1.dup    case match    when /\Aamp\z/ni           then '&'    when /\Aquot\z/ni          then '"'    when /\Agt\z/ni            then '>'    when /\Alt\z/ni            then '<'    when /\A#(\d+)\z/n         then Integer($1).chr    when /\A#x([0-9a-f]+)\z/ni then $1.hex.chr    end  }  strend