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

Split function

P: n/a
Reb
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi

use Split overloaded method.

public string[] Split(
params char[] separator
);

Parameter is An array of Unicode characters that delimit
the substrings in this instance, an empty array
containing no delimiters, or a null reference (Nothing in
Visual Basic).

HTH

Ravikanth[MVP]
-----Original Message-----
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb
.

Nov 15 '05 #2

P: n/a
The split function just examines individual characters to determine whether
they're delimiters.

If you want to "split" by an entire string, like splitting "xyzzy name
foobar" into "xyzzy" and "foobar," you'll need to use regular expressions
(in the System.Text.RegularExpressions namespace.) The overloaded Split
function will check for individual character delimiters (e.g., "f", "o" "b"
"a" or "r") but not entire strings. Alternatively, you could roll your own
function.

"Reb" <gb***@yahoo.com> wrote in message
news:12****************************@phx.gbl...
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb

Nov 15 '05 #3

P: n/a
Reb,
In addition to RegEx.Split as Robert suggests, you could use
Microsoft.VisualBasic.Strings.Split which splits based on a string.

Alternatively you could create your own Split function using String.IndexOf
& String.SubString. Or use String.Replace to replace each delimiter string
with a distinct char ('\0' per haps), then use String.Split on this char.

Hope this helps
Jay

"Reb" <gb***@yahoo.com> wrote in message
news:12****************************@phx.gbl...
Hi,

I could split only by a character. How do i split by a
string.
How can i do something like this.
e.g., somestring.Split("name");

Thanks
Reb

Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.