SQL Server REGEXP_REPLACE for Email Normalization
Short answer
C Use REGEXP_REPLACE to substitute the substring from the plus sign up to the @ symbol with just the @ symbol.
Question

Data analysis shows that some customers have subaddressing in their email address, for example, [email protected] .
You need to return a normalized email value that removes the subaddressing, for example, user1 [email protected] must be normalized to [email protected] .
Which Transact-SQL expression should you use?
Key Takeaways
The key is understanding how regex replacement works: you must match the unwanted portion (from the plus sign up to the @ symbol) and replace it with just the @ symbol, preserving the domain.
This question tests the ability to use regular expressions in T-SQL to normalize email addresses by removing subaddressing (the plus sign and everything following it). The correct expression uses a regex pattern that matches the plus sign up to the domain separator.
Common mistake: Learners often choose option A, which replaces everything from the plus sign to the end of the string. This incorrectly removes the domain name (e.g., 'example.com'), leaving only the local part without a valid email format.
Expert Analysis
Why the Answer Is Correct
Option C is the correct choice because the regex pattern '\+.*@' specifically targets the plus sign, any characters following it (non-greedy or greedy until the next specific delimiter), and stops at the '@' symbol. By replacing this matched sequence with just '@', the subaddressing is removed while retaining the full domain. For example, '[email protected]' becomes '[email protected]'.
Why the Other Options Are Wrong
Option A replaces '\+.$' (plus sign to end of string) with an empty string, resulting in 'user1' without the domain. Option B uses REGEXP_SUBSTR (which extracts rather than replaces) and has a syntax error with '=)' at the end. Option D replaces '\+.' (plus sign to end of string) with an empty string, also dropping the domain.
Community Comment Notes
One commenter noted that '$' means until the end of the string, correctly identifying why Option A fails to preserve the domain. Another user questioned if removing the plus and everything after leaves just the username, highlighting the common confusion between stripping the suffix versus stripping the entire rest of the string.
Exam Strategy
When using regex replacement, always verify what remains after the substitution. If you are removing text, ensure you aren't accidentally deleting necessary parts like the domain in an email address. Use '@' as a boundary marker when dealing with emails.
Frequently Asked Questions
Why does Option A fail to normalize the email?
What does the regex \+.*@ actually match?
Discussion 4 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 4
-
dabhelia 👍 1 Answered CWhy C is correct: JSON_VALUE(Payload, '$.customer_email') pulls the email string out of the JSON document. + matches a literal plus sign, .* matches the subaddress tag, and @ anchors the match at the start of the domain. Replacing that match with @ removes only the tag and keeps the local part and the domain. An address without a + doesn't match the pattern, so it's returned unchanged.
-
Jaz_Muthini 👍 1wait... but does that not mean remove the plus sign and everything after it, leaving us with just user1 ?
-
Sr18 👍 1 Answered CC: Pattern provided will remove anything from + to last @ and replacing it with @ will do the work.
-
BeingAbhi 👍 1 Answered A$ means until the end of the string. So, A is correct.
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.