3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $mails = array( 'a.yamada@yamada.com', 'a.yamada@sub.yamada.com', 'a.yamada@sub.sub.yamada.com', 'a.yamada@sub.sub.sub.yamada.com', 'a.yamada@sub.sub.sub.yamada.com', 'a.yamada@yamada.net', 'a.yamada@sub.yamada.net', 'a.yamada@sub.sub.yamada.net', 'a.yamada@sub.sub.sub.yamada.net', 'a.yamada@sub.sub.sub.yamada.net', ); foreach ($mails as $mail) { if (preg_match('/@([^.]+\.){0,}yamada.com$/', $mail)) { echo "${mail} -> DISCARD\n"; } else { echo "${mail} -> OK\n"; } }
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
a.yamada@yamada.com -> DISCARD a.yamada@sub.yamada.com -> DISCARD a.yamada@sub.sub.yamada.com -> DISCARD a.yamada@sub.sub.sub.yamada.com -> DISCARD a.yamada@sub.sub.sub.yamada.com -> DISCARD a.yamada@yamada.net -> OK a.yamada@sub.yamada.net -> OK a.yamada@sub.sub.yamada.net -> OK a.yamada@sub.sub.sub.yamada.net -> OK a.yamada@sub.sub.sub.yamada.net -> OK