preg_match() returns false but no documentation why

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

 



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." $$

[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