I am trying to find email addresses from the HTML file, I need email addresses with top-level domain(tld) to level 1 only, for example from the email addresses given below, bold addresses are invalid in this case
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
I am using the following regex it works fine if there are only email addresses, but if I add any text after the email addresses it doesn't match the criteria.
(?=<\s|^)\b[a-zA-Z0-9.-]+@[a-zA-Z0-9-]+.[a-zA-Z]{2,6}$(?=\s|$|.+)
success case:
Failure case:
- [email protected] random text after email address
- [email protected] random text after email address
- [email protected] random text after email address
Any help in this scenario will be really appreciated.