Exercise · beginner · 8 min
Normalize emails under a declared policy
This system treats email addresses as case-insensitive. Trim and lowercase them — and do nothing else: dots and plus tags stay.
The rules
These rules decide what a correct result is. Your answer is checked on this dataset and on hidden datasets that follow the same rules.
Input contacts(id, email) — text. id is unique. Emails are ASCII and always present. Rules (this fictional system's declared policy) email: remove ASCII whitespace (space, tab, CR, LF) at both ends, then lowercase the whole address. Do not remove dots, plus tags or anything else; do not merge contacts. Running the rule twice changes nothing. Output (row order does not matter) clean(id text, email text)
The data
contacts · 12 rows
| id | |
|---|---|
| c2e40 | ·s.am@Shop.Example.net· |
| co4rf | ··carol_99@MAIL.example.org·· |
| cf5co | Sam+offers@example.COM |
| c3vyo | ··carol_99@Example.com·· |
| cgbcs | ·bob@example.com· |
| cmnxs | ··Sam+offers@Shop.Example.net·· |
| crnsn | ·s.am@example.COM· |
| c8m37 | ··sam+offers@mail.example.org·· |
| c7og7 | ··s.am@MAIL.example.org·· |
| cghwl | ··carol_99@MAIL.example.org·· |
| c80if | ·Ann.Lee@Example.com·· |
| c942l | dan+news+2026@example.com |
What you practise
- text
- policies
- idempotence
Your answer is also checked on hidden datasets generated from the same rules.
Sign in to bookmark this and keep private notes.