Re: preg_match() returns false but no documentation why

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

 



On 5/30/07, Jim Lucas <lists@xxxxxxxxx> wrote:

The op will need to use something other than forward slashes.


You mean the delimiters (a la Richard's suggestion about using '|')?

so, this is going to match:
ldap://testing123.com           TRUE
ldap://www.testing-123.com      FALSE
ldap://testing123.com.uk        FALSE
ldap://testing123.or.us         TRUE


Hmm. What makes them fail/not fail? The '//' in the pattern?

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

I also recommend using single quotes instead of double quotes here.


Single Quotes: Noted. Any reason why? I guess you might be a little out of
luck putting $vars into a regex without . concatenating.

why is there a period in the second pattern?

The period comes from the original article on SitePoint (linked earlier). Is
it unnecessary? I can't say I'm real sure what this means for the '.' in
regex's:

"Matches any single character except line break characters \r and \n. Most
regex flavors have an option to make the dot match line break characters
too."
- http://www.regular-expressions.info/reference.html

Also, why are you allowing for uppercase letters
when the RFC's don't allow them?

I hadn't gotten far enough to strtolower(), but that's a good point, I
hadn't actually considered it yet.

Just my thoughts


Hey, I appreciate it!

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