PC Review


Reply
Thread Tools Rate Thread

The best way to split a string by bracket

 
 
DAXU@HOTMAIL.COM
Guest
Posts: n/a
 
      14th Feb 2007
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

 
Reply With Quote
 
 
 
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      14th Feb 2007
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"

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
DAXU@HOTMAIL.COM
Guest
Posts: n/a
 
      15th Feb 2007
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

On 14 Feb, 21:17, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.com> wrote:
> 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"
>
> <D...@HOTMAIL.COM> wrote in message
>
> news:(E-Mail Removed)...
>
> > 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



 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      16th Feb 2007
Hi,

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



--
Ignacio Machin
machin AT laceupsolutions com


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I split a string or use the split function in design view? Michelle Microsoft Access Queries 3 31st May 2009 09:23 PM
.net 2.0 split and knowing which seperator was used to split the string Digital Fart Microsoft C# .NET 2 16th Jan 2006 04:47 PM
save the whole string into a field and use a string array to split =?Utf-8?B?Q3VyaWU=?= Microsoft Access VBA Modules 4 20th Aug 2005 01:33 PM
String.Split(), Regex.Split() - empty String Rico Microsoft C# .NET 3 27th Jun 2005 04:26 PM
String.Split versus Strings.Split kurt sune Microsoft VB .NET 5 30th Mar 2005 04:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:59 AM.