|
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]
|