CSharp examples for System:String Split
Splits the text with spaces.
using System.Text.RegularExpressions; using System.Collections.Generic; using System.Text; using System;/* w ww. j a v a 2s .c o m*/ public class Main{ /// <summary> /// Splits the text with spaces. /// </summary> /// <param name="text">The text.</param> /// <returns></returns> public static string[] SplitWithSpaces(string text) { string pattern = "[^ ]+"; Regex rgx = new Regex(pattern); MatchCollection mc = rgx.Matches(text); string[] items = new string[mc.Count]; for (int i = 0; i < items.Length; i++) { items[i] = mc[i].Value; } return items; } }