private Match?GetMatch(int i) { Debug.Assert(i >= 0, "i cannot be negative."); if (_matches.Count > i) { return(_matches[i]); } if (_done) { return(null); } Match match; do { match = _regex.RunSingleMatch(false, _prevlen, _input, 0, _input.Length, _startat) !; if (!match.Success) { _done = true; return(null); } _matches.Add(match); _prevlen = match.Length; _startat = match._textpos; } while (_matches.Count <= i); return(match); }
/// <summary> /// Advances the enumerator to the next match in the span. /// </summary> /// <returns> /// <see langword="true"/> if the enumerator was successfully advanced to the next element; <see langword="false"/> if the enumerator cannot find additional matches. /// </returns> public bool MoveNext() { (bool Success, int Index, int Length, int TextPosition)match = _regex.RunSingleMatch(RegexRunnerMode.BoundsRequired, _prevLen, _input, _startAt); if (match.Success) { _current = new ValueMatch(match.Index, match.Length); _startAt = match.TextPosition; _prevLen = match.Length; return(true); } return(false); }