Re: preg_match problem

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

 



On p, 2007-01-19 at 15:39 +0000, Roman Neuhauser wrote:
> # znemeth@xxxxxxxxxxxxxx / 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


[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