The best way to split a string by bracket

  • Thread starter Thread starter DAXU
  • Start date Start date
D

DAXU

Hi,
If I have string like:
a=(adfd(aa)aa(bb)c(dd))

What is the best way to split the string to:
adfd
(aa)
(bb)
c
(dd)

I can only think of string.split.

Many Thanks

Jerry
 
Hi,

String.Split will not work here, you will have to make your own rutine. It's
not too dificult just keep the current state (presence of either "(" or
")" ) in a variable and when you find the a new set you know you got another
part.

Make sure to take into account incorrected formed strings like "
adfd(a(a)aa"
 
Hi,
Thanks. I know I can do it by keep the position of "(" and ")".
What do you think of creating a steate machine to do it? have some
example for me to start with?
Many Thanks
Jerry
 
Hi,

Hi,
Thanks. I know I can do it by keep the position of "(" and ")".
What do you think of creating a steate machine to do it? have some
example for me to start with?
Many Thanks
Jerry

That is the way to go, about examples. well you can always google for them
:)
 
Back
Top