Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2005

Tip: Looking for answers? Try searching our database.

Using Regex and string.split

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christos - 28 Jul 2005 10:47 GMT
Hello there,
i am trying to parse a string expression. The expression looks like this

str = {cc, 1}+{cc, 2}
delimeters =  '{', ',', '}'

ant i want to get the result:

cc
1
+
cc
2

Initially i used string.split(str, delimeters) but it returns spaces as
words. I tried Regex but unfortunately i didn't get it to work (or in other
words confused with \#[]#?* etc :)

Any help?

Thanks in advance...

Christos
larrylard@hotmail.com - 28 Jul 2005 15:24 GMT
> Hello there,
> i am trying to parse a string expression. The expression looks like this
[quoted text clipped - 13 lines]
> words. I tried Regex but unfortunately i didn't get it to work (or in other
> words confused with \#[]#?* etc :)

Remove all spaces before using Split? (eventually *someone* will pass
something where space is used as a delimiter, but what can you do?)

Signature

Larry Lard
Replies to group please

Oliver Sturm - 28 Jul 2005 16:26 GMT
> Initially i used string.split(str, delimeters) but it returns spaces as
> words. I tried Regex but unfortunately i didn't get it to work (or in other
> words confused with \#[]#?* etc :)

Splitting with this regular expression should work fine for a start:

,|\{|\}

As Larry mentions, you might want to get rid of the spaces beforehand,
as well as the line prefix ("str ="). You could use a regex for this :-)

A regex replace of " |str\s*=" (without the quotes) with "" (nothing)
should do it.

               Oliver Sturm
Signature

omnibus ex nihilo ducendis sufficit unum
Spaces inserted to prevent google email destruction:
MSN oliver @ sturmnet.org Jabber sturm @ amessage.de
ICQ 27142619 http://www.sturmnet.org/blog


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.