You are here: Re: Matching user inputed regexp « PHP Programming Language « IT news, forums, messages
Re: Matching user inputed regexp

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация