Re: preg_match question
| From: | Chris Jenkinson | Date: | Wed, 18 Aug 2004 22:25:01 +0000 |
| Subject: | Re: preg_match question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-194202@lists.php.net to get a copy of this message | ||
Nicklas Bondesson wrote:
How do I find an exact match of a string with preg_match? Example: String1: www.test.com/ String2: www.test.com/somepage.php?param1=true How do you write the regexp to only return String1 and not String2 when you match against "www.test.com" ??You should use the ^ and $ characters which signify the start and the end of the string respectively. For example: $matched = preg_match('/^www\.test\.com$/', $string); For more information look at the Pattern Syntax page: --> http://php.net/manual/en/reference.pcre.pattern.syntax.php Chris -- Chris Jenkinson chris@starglade.org