Re: Regular Expression
| From: | Ryan Carmelo Briones | Date: | Tue, 18 May 2004 17:10:56 +0000 |
| Subject: | Re: Regular Expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186494@lists.php.net to get a copy of this message | ||
Chris Boget wrote:
Why isn't my regex working? From everything that I've read, it should be... <script language="php"> $string = "[joebob]"; if( preg_match( '/\[(\s+)\]/i', $string, $aMatches )) { print_r( $aMatches ); } else { echo 'No match was found' . "\n\n"; } </script> Chris your regex is matching one or more whitespace characters between [ and ]. i think you wanted \S and not \s. see: http://www.php.net/manual/en/pcre.pattern.syntax.phpRyan Briones