Re: Checking for character absence with regular expressions

From: Date: Fri, 16 Jul 2004 15:50:16 +0000
Subject: Re: Checking for character absence with regular expressions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-190721@lists.php.net to get a copy of this message
> I need to check that the substring " R" (that's a space followed by an > uppercase R) is not contained within my haystack. Just one way to do it: $strings[] = 'Blah Blah R 99.99'; $strings[] = 'Blah Blah R99.99'; $strings[] = 'Blah Blah 99.99CR'; foreach($strings as $value) { if (preg_match('/\sR/', $value)) { echo 'A match was found in '.$value.'<br />'; } else { echo 'A match was not found '.$value.'<br />'; } }

« previous php.general (#190721) next »