Re: preg_match too greedy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/29/2009 11:18 PM, Daniel Kolbo wrote:
b wrote:
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.


i am not talking about the delimiter
your pattern is:
%^/foo/?$%U
your test string is:
'foo/bar'

AAARRRGGHHHH! Sorry, that's a typo! It should be:

$test = '/foo/bar';

I guess that explains a lot. For the record, I had to type that in because this latest version of Thunderbird crashes whenever I paste into it. (note to self: downgrade that, stat!)





--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux