Hi Monks,
I am trying to split a string delimited at the longest balanced-bracket, i.e., in a greedy way.
For example, I want to split the string shown below into two parts: i) 'The use of parentheses.', and ii) '(indicates that the (writer [considered] the {information}) less <important-almost> an afterthought)'.
While part ii) could be obtained using the code below, I am not sure how to get the remaining part of the string, i.e., part i). I also tried to work with 'Text::Balanced' module but couldn't make it work.
Thank you for suggestions.
use Regexp::Common 'RE_ALL'; my $string='The use of parentheses (indicates that the (writer [consid +ered] the {information}) less <important—almost> an afterthought).'; $string =~ RE_balanced(-parens=>'(){}[]<>'} and print "$1\n";
In reply to bracket processing by rajaman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |