replacing special characters

Create clean email addresses in Coda

Replacing special characters with standard letters

Christiaan Huizer

--

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 start by splitting the names into individual letters. A common technique is to split the string by an empty delimiter. As you can see below, this results in a list of all the letters. However, we need to evaluate each letter. For this, we use a loop function — ForEach() in Coda, which I recently discussed in a blog post.

splitting the names into letters

The next step involves applying a filter in conjunction with the Contains() function. Contains() is inherently designed to work with lists of items. In this case, we have a list of all the letters for each name. The helper table (highlighted in purple below) shows that I've applied the same splitting method to the display column, resulting in a list of special characters. Here — in the purple part — , a Foreach loop isn't necessary.

We search for a match using a filter that compares each letter against the split strings in the helper table. When a match is found, we label it accordingly. It’s important to note that if the filter’s result isn’t blank, it signifies a match.

The following step involves a pattern I’ve frequently used in more complex solutions. It’s quite simple, as illustrated in the screenshot using “Hélène” as an example. If no match is found (which is the case for most letters), the original letter is retained. However, when a match occurs, the corresponding value from the helper table is used instead. In Hélène’s name, for instance, we have two matches : é and è.

when a match occurs we replace, if not we take the original letter

This approach is both simple and elegant. As you can see, it generates a list of letters, with some grouped in square brackets as sub-lists, while others remain as individual letters within the main list. These elements form the foundation for the last step.

In the final step, we combine all the letters using the Concatenate() function, as shown in the screenshot. This gives us the complete names, ready for email creation. While others might use Join("") to reassemble the string, I've found that Concatenate() offers certain advantages, which I'll may explore in a future blog post.

final step

The Regex solution

This was the solution I originally planned to write about. However, as you’ve seen, it’s unnecessary. It largely follows the same pattern, differing mainly in the initial steps. The simpler logic was possible because our data was already clean and correctly formatted. Regular expressions are most useful (though challenging and demanding) when the elements you’re looking for are embedded within larger pieces of unstructured data, such as papers, letters, or notes.

The regex solution you don’t need

Hopefully, this post has shed some light on this common Coda challenge and empowered you to create more interactive and insightful data experiences. On a personal note, creating these in-depth posts takes a lot of time and effort. While I love sharing my knowledge, a little support goes a long way. If you found this helpful, what about a donation or sharing this post with your fellow Coda enthusiasts? Every bit of encouragement helps fuel the next 52 blockbusters!

My name is Christiaan, and I regularly blog about Coda. While this article is free, my professional services (including consultations) are not, but I’m always happy to chat and explore potential solutions. You can find my free contributions in the Coda Community and on X. The Coda Community is a fantastic resource for free insights, especially when you share a sample doc.

--

--

Christiaan Huizer
Christiaan Huizer

Written by Christiaan Huizer

I write about how to Coda . You find blogs for beginners and experienced makers. I publish about 1 / week. Welcome!

No responses yet