Email Address Validator
Difficulty: Medium · Topics: String Parsing, Validation, Regex · Acceptance: 12.5% of 8 submissions
Difficulty: Medium | Tags: Regex, Validation, String Parsing
Description
Given a string, determine if it is a valid email address. The input may optionally include a display name in the format "Display Name .
Implement:
isValidEmail(email) → boolean
Examples
Example 1:
Input: "[email protected]"
Output: true
Example 2:
Input: "Alice Smith <[email protected]>"
Output: true
Example 3:
Input: "invalid-email"
Output: false
Example 4:
Input: "[email protected]"
Output: false
Example 5:
Input: "[email protected]"
Output: true
Example 6:
Input: "@domain.com"
Output: false
Rules
<...> if display name format is used.@.+/-, can contain !#$%&'*+/=?^_{|}~..Constraints
- Input string length ≤ 500.
- Unicode letters are allowed (internationalized emails).
- Leading/trailing whitespace should be trimmed.
---
## Pagination