Stivo - 2009-12-30

Actually, hexadecimal is also allowed to for the &# expressions.
So:
val = val.replaceAll( "&(?!(#\\d+;|#x[0-9a-fA-F]+;|amp;))", "&");
is better.