Re: preg_match() returns false but no documentation why

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

 



On Wed, May 30, 2007 4:25 pm, Jared Farrish wrote:
> On 5/30/07, Richard Lynch <ceo@xxxxxxxxx> wrote:
>>
>> If you can't find them documented, print them out:
>>
>> echo "PREG_NO_ERROR: '", PREG_NO_ERROR, '";
>>
>
> Doh!
>
> PREG_NO_ERROR: 0
> PREG_INTERNAL_ERROR: 1
> PREG_BACKTRACK_LIMIT_ERROR: 2
> PREG_RECURSION_LIMIT_ERROR: 3
> PREG_BAD_UTF8_ERROR: 4
>
> So apparently, "PREG_NO_ERROR" is synonymous for "you need delimiters,
> egghead."

I think the error mechanism you are checking never even had a chance
to kick in...

It's kind of like an in-flight warning system for an airplane that
never got off the ground...  It's going to keep saying "no error"
while the plane burns to a cinder if it never got turned on in the
first place as it never got in the air.

preg_match("/^ldap(s)?:\/\/([a-zA-Z0-9-])+\.[a-zA-Z.]{2,5}$/",$this->server)
>>
>> Try using | instead of / for your delimiter, so that you don't have
>> to
>> dink around with escaping the / in the pattern...
>
>
> You only have to escape "/" if  it's part if it's the pattern
> delimiter?
>
> Makes the code less cluttered and more clear.
>
>
> Fo' sho'.

Yup.

You only need to escape the delimiter you chose if it's in the pattern.

Or, looking at it from the pattern point of view:  Pick a delimiter
you are unlikely to ever need in the pattern, so you won't need to
escape it.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
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