Re: preg_match too greedy

From: Date: Thu, 30 Jul 2009 02:19:31 +0000
Subject: Re: preg_match too greedy
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-296045@lists.php.net to get a copy of this message
On 07/29/2009 07:48 PM, Daniel Kolbo wrote:
code works (no match) for me too on php 5.2.6 build date May 2 2008 18:01:20 with dumbdows NT. preg_match fails but for a reason other than what I think you may be expecting. It fails b/c of the first forwards slash in $url. The regex engine doesn't even get past the second character let alone reaching the end of line anchor.
The forward slash shouldn't be an issue as the delimiter is '%'. The full pattern is: %^/foo/?$%U
Also, your code works (no match) with this first forward slash removed: $url = 'foo(/)?'
But the string happens to start with a forward slash.

« previous php.general (#296045) next »