What is the best Regular Expression to validate an email address in PHP? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

What is the best Regular Expression to validate an email address in PHP?

Damian99Damian99 USAPosts: 116Member

I need to know the best regex to catch a valid email address for my web app. Please help.

Comments

  • newmindcorenewmindcore YekaterinburgPosts: 1Member

    I am using this
    '/[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/is'
    in most cases

  • DavidMDavidM USAPosts: 342Member

    Well, there is no PERFECT regex for this. The best way is coding your app to validate the email by confirmation where you will send an email to that email address with a confirmation link. Until the confirmation is done, you can limit access to your site.

    This tutorial nicely explains how to setup confirmation.

Sign In or Register to comment.