|  | Posted by  steven.rojas on 07/05/07 15:11 
On 4 jul, 04:40, Orin <sava...@ukr.net> wrote:> Hello!
 >
 > I'm using php and have a complicated task, so if someone can
 > understand it then please help me to solve it
 >
 > The task is to make function, that will understand user-inputed regexp
 > and perfome some    actions with inputed regexp.
 >
 > For example:
 >     'categories: ".*" -"foo"' means "all categories, but not 'foo'"
 >     'categories: "foo[a-b]*" ".*bar"'
 >    The regexp are not case-sensitive.
 >
 >  A '-' (dash) preceeding a categoryname means "do not select this
 >    category".
 >
 >  Here is the function that is ok for ".*" but not for ".* -foo":
 >
 > function cheaker ($string ,$patterns) {
 >         $patterns_list = explode(" ", $patterns);
 >         foreach($patterns_list as $cs)
 >                 $res = eregi($cs, $string, $regs);
 >         return $regs[0];
 >
 > }
 
 Your input string is ".* -foo" or '".*" -"foo"'? because is the second
 one, the explode return '.*' and '-foo' but is the first one it return
 '.* -foo' and I think that you don't expect that.
  Navigation: [Reply to this message] |