

If a match is found at the beginning or the end of the input string, an empty string is included at the beginning or the end of the returned array. ' The example displays the following output: The example displays the following output:ĭim regex As Regex = New Regex("-") ' Split on hyphens.ĭim substrings() As String = regex.Split("plum-pear") String substrings = regex.Split("plum-pear") Regex regex = new Regex("-") // Split on hyphens.
#Learn regex code#
For example, splitting a string on a single hyphen causes the returned array to include an empty string in the position where two adjacent hyphens are found, as the following code shows. If multiple matches are adjacent to one another, an empty string is inserted into the array. If no delimiter is found, the return value contains one element whose value is the original input string. The string is split as many times as possible. The Regex.Split methods are similar to the String.Split(Char) method, except that Regex.Split splits the string at a delimiter determined by a regular expression instead of a set of characters. For more information about time-outs, see the Remarks section. Additional parameters specify options that modify the matching operation and a time-out interval if no match is found.Ī time-out occurred. Splits an input string into an array of substrings at the positions defined by a specified regular expression pattern. Split(String, String, RegexOptions, TimeSpan) Specified options modify the matching operation. The search for the regular expression pattern starts at a specified character position in the input string. Splits an input string a specified maximum number of times into an array of substrings, at the positions defined by a regular expression specified in the Regex constructor. Splits an input string into an array of substrings at the positions defined by a regular expression pattern. Splits an input string into an array of substrings at the positions defined by a regular expression pattern specified in the Regex constructor. Splits an input string into an array of substrings at the positions defined by a regular expression match.
