Re: preg_match() returns false but no documentation why

From: Date: Thu, 31 May 2007 22:21:35 +0000
Subject: Re: preg_match() returns false but no documentation why
References: 1 2 3 4 5 6 7  Groups: php.general 
Request: Send a blank email to php-general+get-255944@lists.php.net to get a copy of this message
On Wed, May 30, 2007 4:25 pm, Jared Farrish wrote: > On 5/30/07, Richard Lynch <ceo@l-i-e.com> 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?

« previous php.general (#255944) next »