Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

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, " ");

"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
Posted

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>");

Visit...Bassic Software
  • *Experts*
Posted

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)

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...