Valid email address format regex

A valid email address format can be matched using the following regular expression:

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

Here's a breakdown of what each part of the regex matches:

This regex matches most common email address formats, but it's not foolproof and may not match all valid email addresses. For example, it doesn't allow for internationalized domain names (IDNs) or non-ASCII characters in the local part of the email address.

If you need to match a wider range of email addresses, you can use a more complex regex pattern, such as:

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

This regex pattern allows for multiple domain extensions (e.g., example.com.uk) and matches most common email address formats. However, it's still not perfect and may not match all valid email addresses.

It's worth noting that email address validation is a complex topic, and it's often better to use a dedicated email validation library or service rather than relying on a regex pattern alone.