I’m not sure I fully understand what you want to do, but this example might give you a sense:
def replace_characters(string) do
to_replace = ["&", "<", ">", "/", "'"]
String.replace(string, to_replace, fn
"&" -> "H"
"<" -> "E"
">" -> "L"
"/" -> "L"
"'" -> "O"
end)
end
iex::1> Module.replace_characters("fdsfd &<>/' dsfds")
"fdsfd HELLO dsfds"
Anonimous function is arity 1, that’s why it complains.






















