Only replace symbols with their corresponding value if the symbol is defined

This avoids replacing a substring like x0123 in hex constants with
an empty string.