Your browser (Internet Explorer 6) is out of date. It has known security flaws and may not display all features of this and other websites. Learn how to update your browser.
X

Regex for specific email domain - PHP

I ran into the issue of checking emails with regex to be sure it is only valid for a specific domain. I searched through the internet for hours without reasonable joy, so I decided to write mine. I am not sure how perfect this looks but it just works for what I needed it for.

If you have this same issue, below is the pattern I used.

/[_a-z0-9-]+(\.[_a-z0-9-]+)*@(?i)mydomain.com/

You can savely change "mydomain" to whatever you want.

I hope this keeps the shit away from the fan for someone.

 


comments powered by Disqus