Click or drag to resize

RegexExtensionsSplitT Method

Splits an input string into an array of substrings at the positions defined by the regex regular expression.

Namespace: TomsToolbox.Essentials
Assembly: TomsToolbox.Essentials (in TomsToolbox.Essentials.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax
public static IEnumerable<T> Split<T>(
	this Regex regex,
	string input,
	Func<string, bool, T> itemGenerator
)

Parameters

regex  Regex
The regular expression used to split the string.
input  String
The string to split.
itemGenerator  FuncString, Boolean, T
The item generator used to generate the individual fragments to return. It will get the items string value plus a boolean indicator whether the item was a match or the text in between the matches.

Type Parameters

T
The type of the returned items.

Return Value

IEnumerableT
The items generated by the itemGenerator, an alternating list of non-matched and matched fragments.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Regex. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
Similar to Split(String), but returns and alternating list of both matches and non-matches. It's up to the item generator how matched and non-matched items are handled. Concatenating all unmodified fragment values will always return the original string.
See Also