In this recipe, we will demonstrate how to replace codepoints in a string using a match pattern. We will use the
String.replace/4 function to help with this task.
A codepoint, in this context, is the binary representation of a UTF-8 encoded character.
This recipe will be performed inside an IEx session. Start it by executing the
iex command in your command line.
To find a pattern in a string and replace it, follow these steps:
iex(1)> my_string = "email@example.com firstname.lastname@example.org" "email@example.com firstname.lastname@example.org"
iex(2)> my_pattern = "@" "@"