GPT 5.1· openai
Frontier Reasoning Traces
Write a regular expression to validate emails ending in ‘.com’ or ‘.net’.
- User
Write a regular expression to validate emails ending in ‘.com’ or ‘.net’.
- Assistant
Providing simple regex for email validation
The user needs a simple regex for email validation, likely looking for something concise. I think a typical example would be: ^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+.(com|net)$.
I could mention this also works with anchors. It might help to provide explanations in various programming languages too, but I want to keep it simple and straightforward. I’ll clarify that this is a simplified version, avoiding anything overly complex. Use this regular expression:
regex^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.(com|net)$Explanation (brief):
^[A-Za-z0-9._%+-]+– local part of the email (before@)@– required@symbol[A-Za-z0-9.-]+– domain name\.(com|net)$– must end with.comor.net^and$– ensure the entire string is matched (not just part of it).