Regex to check valid email

Here is a commonly used regular expression to validate an email address:

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

Let me break it down:

This regular expression will match most common email address formats, but keep in mind that it's not foolproof and may not match all valid email addresses. For example, it won't match email addresses with internationalized domain names (IDNs) or email addresses with non-ASCII characters.

Here are some examples of valid email addresses that this regular expression will match:

And here are some examples of invalid email addresses that this regular expression will not match:

If you need to validate email addresses in a specific context or according to specific requirements, you may want to consider using a more advanced regular expression or a dedicated email validation library.