By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,508 Members | 1,856 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,508 IT Pros & Developers. It's quick & easy.

split() question

P: n/a
KC
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't know
how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken
Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"KC" <yo*@dontneed.this> skrev i en meddelelse
news:uI*************@TK2MSFTNGP11.phx.gbl...
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't know how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken


You have to do like this, atleast I don't know any other way

dim str as string = "234 23 42 234 234 234"
str = str.split(" ")
dim moreSpaces as integer = str.indexof(" ")
while morespaces <> -1
str = str.split(" ")
moreSpaces = str.indexof(" ")
end while
Nov 20 '05 #2

P: n/a
Use Regular Expressions.

"Richard" <s@b.k> wrote in message
news:ea*************@TK2MSFTNGP12.phx.gbl...
"KC" <yo*@dontneed.this> skrev i en meddelelse
news:uI*************@TK2MSFTNGP11.phx.gbl...
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't

know
how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken


You have to do like this, atleast I don't know any other way

dim str as string = "234 23 42 234 234 234"
str = str.split(" ")
dim moreSpaces as integer = str.indexof(" ")
while morespaces <> -1
str = str.split(" ")
moreSpaces = str.indexof(" ")
end while

Nov 20 '05 #3

P: n/a
> dim str as string = "234 23 42 234 234 234"
str = str.split(" ")
dim moreSpaces as integer = str.indexof(" ")
while morespaces <> -1
str = str.split(" ")
moreSpaces = str.indexof(" ")
end while


LOL
My bad I thought i was another operation,
It will work with split, but there might be some empty strings in the array
you are getting
Nov 20 '05 #4

P: n/a
My bad, it will work
Nov 20 '05 #5

P: n/a
Ken,
As Juan suggested, you can use RegEx.Split...

There are three Split functions in .NET:

Use Microsoft.VisualBasic.Strings.Split if you need to split a string based
on a specific word (string). It is the Split function from VB6.

Use System.String.Split if you need to split a string based on a collection
of specific characters. Each individual character is its own delimiter.

Use System.Text.RegularExpressions.RegEx.Split to split based
on matching patterns.

Hope this helps
Jay
"KC" <yo*@dontneed.this> wrote in message
news:uI*************@TK2MSFTNGP11.phx.gbl...
Can I do a split() on a string where the delimiter is one or more space
characters? I have a string with spaces between the numbers but I don't know how many. You can do this easy in Perl, but VB.net ain't Perl...

Ken

Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.