On p, 2007-01-19 at 15:39 +0000, Roman Neuhauser wrote:
> # [EMAIL PROTECTED] / 2007-01-19 15:25:38 +0100:
> > Hi all,
> >
> > I have a simple checking like
> >
> > if (preg_match("/[\w\x2F]{6,}/",$a))
> >
> > as I would like to allow all "word characters" as mentioned at
> > http://hu2.php.net/manual/hu/reference.pcre.pattern.syntax.php
> > plus the '/' character, and at least 6 characters.
> >
> > But it throws
> >
> > Warning: preg_match(): Unknown modifier ']'
> >
> > and returns false for "abc/de/ggg" which string should be okay.
> > If I omit the "\x2F", everything works fine but "/" characters are not
> > allowed. Anyone knows what I'm doing wrong? Maybe "/" characters can not
> > be put in patterns like this?
>
> 1. You're making your life harder with those double quotes. \x2F is
> interpolated by PHP, before the PCRE library has a chance to see the
> string.
> 2. Use a different delimiter and you'll be able to use slash characters
> in the pattern freely.
>
> preg_match('~[\w/]{6,}~', $a);
>
Thank you very much, it's working fine now.
Zoltán Németh
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php