Modified merged code from ge0rdi (Thanks,your code was much cleaner, hop...

...e you don't mind the changes), changed re.sub in decode(has to compile regex everytime decode is called) to a regex object and pulled re.compile out of decode(now its only compiled once.

combined the re.sub patterns to one pattern to limit the number of times string "s" is parsed over.
Added support for replacing &#xXXXX (http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references)
Added support for replacing entities that have been encoded multiple times(&amp;#039:).
Handling multiple encoded entities is the tricky part if anyone knows of a better way please let know.