Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Regular expression to not accept . at the end of the email address in React

I want to construct a regular expression where . is not allowed as the last and first character of the email address (example: .abc.@gmail.com should not be accepted). Also, I have another requirement that .. 2 consecutives periods should not be allowed anywhere in the email address (example: abc...def@gmail.com).

The regular expression that I am currently using is : let regEx = new RegExp(/^[a-zA-Z0-9+_.-]+@(\[(\d{1,3}\.)(([a-zA-Z\d-]+\.)+))([a-zA-Z]{2,15}|\d{1,3})(\]?)/);.

Can I get some help in modifying the above regular expression to fulfill my requirement?

PS: I have very little knowledge on regular expressions.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Adding your 2 new requirements we can try:

^(?!.*\.\.)[\p{L}\p{N}\s,_-][\p{L}\p{N}\s,._-]*[\p{L}\p{N}\s,_-]$

Explanation:

^                        from the start of the email
    (?!.*\.\.)           no two or more consecutive dots
    [\p{L}\p{N}\s,_-]    first character is not dot
    [\p{L}\p{N}\s,._-]*  zero or more allowed characters, including dot
    [\p{L}\p{N}\s,_-]    last character is not dot
$                        end of the email
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!