|
Posted by Orin on 07/04/07 08:40
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];
}
Navigation:
[Reply to this message]
|