|
Posted by erikcw on 02/24/07 18:05
On Feb 24, 9:45 am, "Janwillem Borleffs" <j...@jwscripts.com> wrote:
> erikcw wrote:
> > Here is what I have so far - it is close, but I keep ending up with
> > duplicate brackets.
>
> [...]
>
> Often, simplicity = bless:
>
> $PATTERNS = array('/(\[|\])/', '/([^\r\n]+)/');
> $REPLACEMENTS = array('', '[$1]');
>
> JW
Thank you for your reply.
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 **.
So, the output should look like this:
$input = 'this
is
a
test
"this"
"is"
"a"
[this]
[is]
[a]
test ** 93.23
test 2 ** 10.05
-this
-is
-a
another good test
';
$OUTPUT = '[this]
[is]
[a]
[test]
"this"
"is"
"a"
[this]
[is]
[a]
[test] ** 93.23
[test 2] ** 10.05
-this
-is
-a
[another good test]
';
What needs to be changed in your pattern to do this?
Thanks so much!
Erik
Navigation:
[Reply to this message]
|