I'd go for a KISS approach to apply multiple replacements of non nested pairs with placeholders.
0: The use of parentheses (indicates that the (writer [considered] the {information}) less <important—almost> an afterthought).
1: The use of parentheses (indicates that the (writer %0% the %1%) less %2% an afterthought).
2: The use of parentheses (indicates that the %3% less %2% an afterthought).
3: The use of parentheses %4%.
This can be done by repeating one simple regex over and over and storing the matches in an array. Afterwards you just need to reconstruct the tree again.
NB: I just used %n% for visualization. Using something like \0 is far better here.
HTH :)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
In reply to Re: bracket processing
by LanX
in thread bracket processing
by rajaman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |