00 Votes

PHP: Regular Expression to Check an E-Mail Address

Question by Guest | 2015-06-08 at 22:43

Does someone know any regular expression I can use together with preg_match() in PHP in order to check or validate an email address?

I have already tried to create my own regex, but it has not worked properly. Can someone help me? I would like to check the user input of my contact form.

ReplyPositiveNegative
0Best Answer0 Votes

Developing a regular expression that really is able to filter all valid e-mail addresses, is very difficult and complicated.

Instead, I recommend using the function filter_var() which is part of PHP and with which you can quite easily and quickly validate an e-mail address.

Just look at this topic. There you can find an example of how to use filter_var() and you can also find a complex regular expression if you cannot or do not want to use filter_var().
2015-06-08 at 23:09

ReplyPositive Negative
Reply

Related Topics

PHP: Sending an E-Mail

Tutorial | 0 Comments

How to avoid Spam Mails

Tip | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.