正则表达式检查垃圾邮件发送者

I'm trying to figure out the regular expression for preg_match() that would return true for all of the following scenarios:

1- strip spaces for people doing this "check out my website . com (no spaces)"

2- find the obvious "mywebsite.com" in "check out mywebsite.com"

3- find dot replacement "check out mywebsite dot com (no spaces)"

4- be case insensitive

Does this work for you? I think you'll have to modify this in the future but for a rough implementation (what you've asked for) it should work. I also presumed your "check out my" is required text if not that can be removed. The \s* means any amount of whitespace; the \w* means any number of word characters (a-z, 0-9, and/or underscore). The | means "or" and the () groups the two values that "or" should be affecting. If you have questions please ask. The outer most parenthesis group the potential domain. You may want to alter the \w* to \w+ but I'd presume if they're saying "check out my .com" you'd also want to filter it...

if(preg_match('~check\s*out\s*my\s*(\w*\s*(\.|dot)\s*com)~i', $input, $domain)) {
     echo 'This is spam?';
}

A solution based on your actual code:

<?php
$spamCount=0;
$input=preg_replace(array('~\s*~', '~dot~i'), array('', '.'), 'Hi. Please see my website at "test domain . com" (no spaces) anothertest dot com');
$checkTheseDomains = array("testdomain.com","anothertest.com");
foreach($checkTheseDomains as $domain) {
    if(strpos($input, $domain) !== false) {
        $spamCount++;
    }
}
if($spamCount > 0){
        echo "Spam count of  <b>".$spamCount."</b>";
}else{
        echo "No spam";
}