On 5/30/07, Richard Lynch <[EMAIL PROTECTED]> 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."


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


> Now when I add the slashes, I get zero, even though I give it a real
> value
> that should return 1. *sigh*

You may want \\. for the . in dot com


Ok, I tried:

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

using: $this->server = "ldap://www.example.com";;

No luck. I'll the try tool you referred to; I have been using
regular-expressions.info for information.

Download and play with "The Regex Coach"

It does pretty color syntax highlighting of the target string and your
regex to show you what's going on, as well as a slow-motion instant
replay to "step" through it piece by piece.


Oooh, pretty colors! Stepping through sounds interesting. I'll have to check
it out.

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

Reply via email to