Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression for Email with custom domain only [closed]

Hi I need regular expression for Email with custom domain only, means I want to exclude:

@live, @hotmail, @outlook, @aol, @yahoo, @rocketmail, @gmail, @gmx.com, @mail.com, @inbox.com, @icloud, @aim, @yandex, @zoho


2 Answers

Use two regex tests for your candidate strings in a single loop.

  1. In the first test, you check for the unwanted domains and skip the string if you get a match:

    /^[\w-\._\+%]+@(live|hotmail|outlook|aol|yahoo|rocketmail|gmail|gmx\.com|mail.com|inbox.com|icloud|aim|yandex|zoho)\./
    
  2. In the second test, you use your standard email regex.

like image 113
David Avatar answered Jan 03 '26 23:01

David


Add the following immediately after the @ in your email address pattern:

(?!(?:live|hotmail|outlook|aol|yahoo|rocketmail|gmail|
   gmx\.com|mail\.com|inbox\.com|icloud|aim|yandex|zoho)$)

Be sure to use a case-insensitive match.

(Line break added for readability.)

like image 20
ikegami Avatar answered Jan 03 '26 21:01

ikegami



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!