You are here: Re: Trying to prevent duplicates in preg_replace Regex « PHP Programming Language « IT news, forums, messages
Re: Trying to prevent duplicates in preg_replace Regex

Posted by erikcw on 02/24/07 19:43

On Feb 24, 1:54 pm, "erikcw" <erikwickst...@gmail.com> wrote:
> On Feb 24, 1:31 pm, Rik <luiheidsgoe...@hotmail.com> wrote:
>
> > erikcw <erikwickst...@gmail.com> wrote:
> > > Your selution is simple and elegant. Unfortunatly, it puts brackets
> > > around every line. I need it to ignore lines with "" around them, as
> > > well as line that start with a '-' and lines that end in a ** 0.00
> > > need the ending bracket before the **.
>
> > Well, it can be done, but it will be quite cumbersome/clumsy. Let's
> > backtrack: why do you need the data like that?
> > --
> > Rik Wasmus
>
> I need to format the data this way for a legacy system.

What about this:
$PATTERNS = array('/([^\r\n]+)/', '/\[\[(.*)]]/', '/\["(.*)"]/', '/\[-
(.*)]/', '/ \*\* (.*)]/');
$REPLACEMENTS = array('[$1]', '[$1]', '"$1"', '-$1', '] ** $1');

I guess the question is, is it faster to run several small patterns or
to run a single larger pattern that handles all possible cases?

Thanks for your help!
Erik

 

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

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