soccerspice10 Posted September 7, 2004 Posted September 7, 2004 what is the best way to use split function Quote
soccerspice10 Posted September 7, 2004 Author Posted September 7, 2004 How you use split function Quote
*Experts* Bucky Posted September 7, 2004 *Experts* Posted September 7, 2004 I use the Regex.Split() function, which allows you to split a string by a delimeter that is not just a single character. For example, this splits the sentence into multiple words: string[] words; string text = "This is a test, yo."; words = System.Text.RegularExpressions.Regex.Split(text, " "); Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Moderators Robby Posted September 7, 2004 Moderators Posted September 7, 2004 Just to expand on Bucky's sample, and as he mentioned you can split on a series of characters...In this case <test> string[] words; string text = "First Item<test>Second item<test>Third item<test>Forth item"; words = System.Text.RegularExpressions.Regex.Split(text, "<test>"); Quote Visit...Bassic Software
*Experts* Bucky Posted September 7, 2004 *Experts* Posted September 7, 2004 Yeah, if you're just going to split by a single character, like in my example, you could just use the String.Split() method: string[] words; string text = "This is a test, yo."; words = text.Split(' '); // In VB.NET this would be: words = text.Split(" "c) Quote "Being grown up isn't half as fun as growing up These are the best days of our lives" -The Ataris, In This Diary
Moderators Robby Posted September 7, 2004 Moderators Posted September 7, 2004 In case anyone is wondering, the "c" at the end of text.Split(" "c) is simply to cast the character to char when have Option Strict On in your code page. (Which you all should) Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.