Regex.Split Method (String)
Assembly: System (in system.dll)
The Regex.Split methods are similar to the Split method, except this method splits the string at a delimiter determined by a regular expression instead of a set of characters. If count is specified, the string is split into at most count strings (the last string contains the unsplit remainder of the string); a count value of zero provides the default behavior of splitting as many times as possible. If startat is specified, the first delimiter is searched for starting at the specified point (this can be used, for example, for skipping leading white space).
If capturing groups are used in a Regex.Split expression, the capturing groups are included in the resulting string array. The following example would yield the array items "one", "-", "two", "-", "banana".
Regex r = new Regex("(-)"); // Split on hyphens. string s = r.Split("one-two-banana");
If the regular expression can match the empty string (for example, x*), Split will split the string into an array of single-character strings because the empty string delimiter can be found at every location.
The static Split methods are equivalent to constructing a Regex object with the specified regular expression pattern and calling the instance method Split. The static methods are provided to allow an isolated, single use of a regular expression without explicitly creating a Regex object.
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.