RE: [PHP] preg_match too greedy

2009-07-31 Thread Ford, Mike
> -Original Message- > From: b [mailto:p...@logi.ca] > Sent: 30 July 2009 03:17 > > > > > >>> echo (preg_match($pattern, $test) != false) > > > > The " != false " here is redundant. > > Understood. But what you think is redundancy is, to me, clarity in > programming. I happen to think th

Re: [PHP] preg_match too greedy

2009-07-30 Thread Ben Dunlap
Ben Dunlap wrote: > have -- "($x != false)" -- will be true whether $x is 0, NULL, an empty > string, [8<] > But "$x !== false" will only be true in the last case. Sorry, replace "be true" with "be false" above. -Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http

Re: [PHP] preg_match too greedy

2009-07-30 Thread Ben Dunlap
echo (preg_match($pattern, $test) != false) >> >> The " != false " here is redundant. > > Understood. But what you think is redundancy is, to me, clarity in > programming. I happen to think that boolean tests shouldn't ride on > whether or not an array returned from a function is empty or not

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
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 f

Re: [PHP] preg_match too greedy

2009-07-29 Thread Daniel Kolbo
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.

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
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

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
On 07/29/2009 03:03 PM, Ben Dunlap wrote: Jim Lucas wrote: I expected 'no match' but get 'match'. [8<] cut/paste your code and it works for me. Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What version do you have? 5.2.9 If I might suggest a couple of simplifi

Re: [PHP] preg_match too greedy

2009-07-29 Thread b
On 07/29/2009 02:07 PM, Jim Lucas wrote: b wrote: I'm trying to figure out how to test if a string matches *exactly* another string, using a regexp pattern. The manual says that ereg() is deprecated (in favour of what?) and preg_match() is giving me trouble. The problem is that I'm passing the e

Re: [PHP] preg_match too greedy

2009-07-29 Thread Daniel Kolbo
Jim Lucas wrote: > Ben Dunlap wrote: >> Jim Lucas wrote: I expected 'no match' but get 'match'. >> [8<] >>> cut/paste your code and it works for me. >> Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What >> version do you have? > > PHP 5.2.5 with Suhosin-Patch 0.9.6.

Re: [PHP] preg_match too greedy

2009-07-29 Thread Jim Lucas
Ben Dunlap wrote: > Jim Lucas wrote: >>> I expected 'no match' but get 'match'. > [8<] >> cut/paste your code and it works for me. > > Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What > version do you have? PHP 5.2.5 with Suhosin-Patch 0.9.6.2 (cli) (built: Mar 11 200

Re: [PHP] preg_match too greedy

2009-07-29 Thread Ben Dunlap
Jim Lucas wrote: >> I expected 'no match' but get 'match'. [8<] > cut/paste your code and it works for me. Works for me as well. I get 'no match' from PHP 5.1.2, 5.2.6, and 5.2.8. What version do you have? If I might suggest a couple of simplifications that would make it easier to follow/troubles

Re: [PHP] preg_match too greedy

2009-07-29 Thread Jim Lucas
b wrote: > I'm trying to figure out how to test if a string matches *exactly* > another string, using a regexp pattern. The manual says that ereg() is > deprecated (in favour of what?) and preg_match() is giving me trouble. > The problem is that I'm passing the end-of-line delimiter ($) but it > se

[PHP] preg_match too greedy

2009-07-29 Thread b
I'm trying to figure out how to test if a string matches *exactly* another string, using a regexp pattern. The manual says that ereg() is deprecated (in favour of what?) and preg_match() is giving me trouble. The problem is that I'm passing the end-of-line delimiter ($) but it seems to be ignor