On 15Apr2017 14:05, Alan Gauld <[email protected]> wrote:
On 15/04/17 03:17, Palm Tree wrote:
s="2*3+3(8-4(5+6+9))+2+3+3(4/4)"
i want to find expression enclosed in brackets.
i want outputs to be like:
(8-4(5+6+9))
(5+6+9)
(4/4)
You probably could do it with some fancy regex but personally
I'd investigate a proper text parser.
The nested brackets thing is something that regexps generally won't do fully,
because they don't recurse. You could write a regexp to handle up-to-n nestings
for some finite n, but as soon as that gets above something like 2 you're
probably into the "don't use regexps for this" domain.
Cheers,
Cameron Simpson <[email protected]>
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor