Member-only story
Create clean email addresses in
Replacing special characters with standard letters
I was creating a demo document and needed to generate BE email addresses. I combined common first and last names with popular email domains like Gmail and Yahoo, using the Format()
function. Everything worked smoothly until I realized email addresses don't allow special characters like "é" or "ç," which are common in many European languages. While replacing one or two letters isn't difficult, doing it for hundreds of addresses would be tedious. That's where regular expressions came in, at least that was what I assumed for a while. I wrote a blog post on how to apply Regex until I noticed a far simpler solution, which I share here.
My first step was identifying the special characters I needed to replace and their standard letter equivalents. I consulted my Gemini assistant and compiled the following list:
[çčćĉċ] -> c
[èéêë] -> e
[àáâãäå] -> a
[ìíîï] -> i
[òóôõö] -> o
[ùúûü] -> u
[ñ] -> n
[ýÿ] -> y
[æ] -> ae
[œ] -> oe
[ß] -> ss
This gave me a solid foundation. My goal was to ensure that any instance of a special character would be replaced by its corresponding standard letter, resulting in a valid email address.
To replace special characters, we need to examine each character individually. We…