Practical Email Validator

Medium ⏱ 12 min 57% acceptance ★★★★☆ 4.2
Write is_email(text) using re.fullmatch with the practical pattern: one or more word chars/dots/hyphens/plus signs, @, domain labels, and a 2+ letter TLD. Perfect RFC compliance is not the goal — anchoring with fullmatch (vs match/search) is.

Examples

Example 1
Input
is_email('dev+test@data-vix.io')
Output
True
Explanation

Plus addressing and hyphenated domains pass.

Example 2
Input
is_email('bad@@x.com')
Output
False
Explanation

Double @ fails the pattern.

Constraints

  • Use fullmatch, not search.
  • TLD at least 2 letters.

Topics

Regular Expressionsfullmatch

Companies

GoogleSalesforceZoho

Hints

Hint 1

r'[\w.+-]+@[\w-]+(\.[\w-]+)*\.[A-Za-z]{2,}'.

Hint 2

fullmatch demands the entire string conforms.

Loading the Python runtime… Run executes your code and shows printed output; Submit checks your function against this problem's examples.