I want to create a regex in Ruby to restrict my email input to follow the below rules:
[user name]@[domain name].[top-level domain name]
User name may only contain English letters, numbers, plus signs, hyphens, underscores, dots. The plus sign and dot may not appear consecutively.
User name must contain at least one English letter.
Domain name may only contain English letters, numbers, and hyphens.
Top-level domain name may only contain English letters, numbers, and hyphens. Must end with an English letter.
Domain name and top-level domain name must be separated with dots, and the email must contain at least 1 top-level domain name.
here is my regex so far:
/\A[a-zA-Z0-9]((?!\.\.)(?!\+\+)[\w\-+.])*[\w\-]@[a-zA-Z0-9\-]+(?:\.[a-zA-Z0-9\-]*)+[a-zA-Z]\z/
I couldn't find a way to make the user name contain at least one English letter. Is there any way to restrict part of the string before the "@" to follow certain rules?