preg_match() returns false but no documentation why



Hi all,

Can anybody spot why this doesn't seem to be working right? The manual (
http://us2.php.net/preg_match) says it returns "false" on error, but
preg_last_error() returns 0, which I assume points to the "PREG_NO_ERROR"
error code.

<code>
preg_match("^ldap(s)?://[a-zA-Z0-9-]+\.[a-zA-Z.]{2,5}$",$this->server)
</code>

I also tried ereg(), and have searched and gone through the comments. Why
would a regex operation return false?

That may be ugly, since I've not done a lot of regex's yet. I have checked
and $this->server does insert a valid string. What I am trying to do is
validate ldap://com.com and ldaps://com.com and all valid variations of. Is
there something wrong with the regex, or am I pumping an invalid format into
preg_match()?

Incidentally, I stole the last piece (after ldaps://) off a regex for email
addresses (from SitePoint,
http://www.sitepoint.com/article/regular-expressions-php).

Thanks!

--
Jared Farrish
Intermediate Web Developer
Denton, Tx

Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$


Relevant Pages

  • Re: c regex example
    ... error code into a readable string when not zero ... Ok that i did and figured out the regex was invalid aldo it isn't some ...
    (comp.programming)
  • Re: [PHP] preg_match() returns false but no documentation why
    ... On Wed, May 30, 2007 12:33 pm, Jared Farrish wrote: ... Can anybody spot why this doesn't seem to be working right? ... error code. ... Some people have a "gift" link here. ...
    (php.general)
  • regex search and replace
    ... editor and Search/Replace using regex. ... line that has a B in the 10th spot, ... Is there anyone out there that understands regex better than I that can ...
    (comp.lang.perl.misc)
  • Re: makeworld broken on 7 stable?
    ... RELENG_7 branch and tried makeworld. ... It keeps blowing up at the same spot: ... *** Error code 2 ...
    (freebsd-stable)
  • makeworld broken on 7 stable?
    ... Cvsup'd RELENG_7 branch and tried makeworld. ... It keeps blowing up at the same spot: ... *** Error code 2 ...
    (freebsd-stable)