Esempio n. 1
0
 /// <summary>
 /// Creates an instance of the <see cref="ValueMatchEnumerator"/> for the passed in <paramref name="regex"/> which iterates over <paramref name="input"/>.
 /// </summary>
 /// <param name="regex">The <see cref="Regex"/> to use for finding matches.</param>
 /// <param name="input">The input span to iterate over.</param>
 /// <param name="startAt">The position where the engine should start looking for matches from.</param>
 internal ValueMatchEnumerator(Regex regex, ReadOnlySpan <char> input, int startAt)
 {
     _regex   = regex;
     _input   = input;
     _current = default;
     _startAt = startAt;
     _prevLen = -1;
 }
Esempio n. 2
0
            /// <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);
            }