Help, extracting substrings from a string

doubty's Avatar
Light Poster
Hi I have a problem on which Iam working on which requires me to extract substrings from a string as below:

String A(B(A(C(t=0,p>0.1)))) + D(E(t=1,p>0.1))

Substrings needed are: {A(B(A(C(t=0,p>0.1))))+D(E(t=1,p>0.1)),
A(B(A(C(t=0,p>0.1)))),
B(A(C(t=0,p>0.1))),
A(C(t=0,p>0.1)),
C(t=0,p>0.1),
(t=0,p>0.1),
D(E(t=1,p>0.1)),
E(t=1,p>0.1),
(t=1,p>0.1)}

So in effect i have to be able to get all substrings within the brackets.

How can I do it in C

Please help
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Easy: two nested loops and a counter. Outside loop loops over the string looking for an open bracket. Inside loop loops over the string from the outer loop's index looking for the matching bracket.