Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
h(Text) ->
html_escape("") -> "";
html_escape(Text) ->
WithoutAmp = re:replace(Text, "&", "\\&", [global, {return, list}]),
WithoutLt = re:replace(WithoutAmp, "<", "\\&lt;", [global, {return, list}]),
WithoutGt = re:replace(WithoutLt, ">", "\\&gt;", [global, {return, list}]),
re:replace(WithoutGt, "\"", "\\&quot;", [global, {return, list}]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.