I have 9 email patterns. I expect:
- [email protected]
- [email protected]
- [email protected]
- [email protected] are valid emails.
and
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected] are not valid emails.
Then, I have made script of regex like:
regex = r"(^[a-zA-Z_]+[\.]?[a-z0-9]+)@([\w.]+\.[\w.]+)$"
But, email [email protected] is still valid.
How to make the right pattern regex so that email become not valid, and all of email patterns can fit to my expectation?
^(?![a-zA-Z]+\.\d+@)[a-zA-Z_]+(?:\.[a-z0-9]+)?@[\w.]+\.\w+$will do, see demo.^[a-zA-Z]+(?:(?:(?:_[a-zA-Z0-9]+)+\.[A-Za-z0-9]+)|\.[a-zA-Z][a-zA-Z0-9]*)?@\w+(?:\.\w+)+regex101.com/r/Q3TxQc/1