Method regexp.Split
Overload
Returns an array of substrings that in the subject string are delimited by regular expression matches.
public string[] Split(string s, int maxCount = 0, Range? range = null, RXMatchFlags matchFlags = 0)
Parameters
s (string)
Subject string. Cannot be |
maxCount (int)
Maximal count of substrings to get. The last substring contains the unsplit remainder of the subject string. If 0 (default) or negative, gets all. |
range (Range?)
Start and end offsets in the subject string. If |
matchFlags (RXMatchFlags)
Options. The same options also can be set in regexp constructor's flags. Constructor's flags and matchFlags are added, which means that matchFlags cannot unset flags set by constructor. |
Returns
string[] |
Exceptions
ArgumentNullException
s is |
ArgumentOutOfRangeException
Invalid range. |
ArgumentException
|
AuException
The PCRE API function pcre2_match failed. Unlikely. |
Remarks
Element 0 of the returned array is s substring until the first match of the regular expression, element 1 is substring between the first and second match, and so on. If no matches, the array contains single element and it is s.
This function is similar to System.Text.RegularExpressions.Regex.Split.
Examples
var s = "one, two,three , four";
var x = new regexp(@" *, *");
var a = x.Split(s);
for(int i = 0; i < a.Length; i++) print.it(i, a[i]);