internal RefMatchEnumerator(InternalRegex regex, ReadOnlySpan <char> subject, PcreMatchSettings settings) { _regex = regex; _subject = subject; _settings = settings; _match = default; }
public bool MoveNext() { if (_regex == null) { return(false); } if (!_match.IsInitialized) { _match = _regex.CreateRefMatch(); _match.FirstMatch(_subject, _settings, _settings.StartIndex); } else { _match.NextMatch(_settings); } if (_match.Success) { return(true); } _regex = null; return(false); }
private IEnumerable <PcreMatch> MatchesIterator(string subject, PcreMatchSettings settings) { var match = InternalRegex.Match(subject, settings, settings.StartIndex, settings.AdditionalOptions.ToPatternOptions()); if (!match.Success) { yield break; } yield return(match); var baseOptions = settings.AdditionalOptions.ToPatternOptions() | PcreConstants.NO_UTF_CHECK; while (true) { var startIndex = match.GetStartOfNextMatchIndex(); var options = baseOptions | (match.Length == 0 ? PcreConstants.NOTEMPTY_ATSTART : 0); match = InternalRegex.Match(subject, settings, startIndex, options); if (!match.Success) { yield break; } yield return(match); } }
internal PcreRefCallout(ReadOnlySpan <char> subject, InternalRegex regex, Native.pcre2_callout_block *callout) { _subject = subject; _regex = regex; _callout = callout; _oVector = null; }
private MatchData ExecuteMatch(MatchContext context) { try { return(InternalRegex.Match(context)); } catch (MatchException ex) { throw PcreMatchException.FromException(ex); } }
internal PcreRefMatch(ReadOnlySpan <char> subject, InternalRegex regex, ReadOnlySpan <uint> oVector, char *mark) { // Callout Subject = subject; _regex = regex; _oVector = oVector; _markPtr = mark; _resultCode = oVector.Length / 2; }
internal PcreRefMatch(InternalRegex regex, ReadOnlySpan <uint> oVector) { // Empty match _regex = regex; _oVector = oVector; Subject = default; _markPtr = null; _resultCode = 0; }
internal PcreMatch(string subject, InternalRegex regex, uint[] oVector, char *mark) { // Callout Subject = subject; _regex = regex; _oVector = oVector; _markPtr = mark; _resultCode = oVector.Length / 2; }
internal PcreMatch(string subject, InternalRegex regex, ref Native.match_result result, uint[] oVector) { // Real match Subject = subject; _regex = regex; _oVector = oVector; _markPtr = result.mark; _resultCode = result.result_code; }
public bool IsMatch(ReadOnlySpan <char> subject, int startIndex) { if (startIndex < 0 || startIndex > subject.Length) { throw new IndexOutOfRangeException("Invalid StartIndex value"); } var outputVector = InternalRegex.CanStackAllocOutputVector ? stackalloc uint[InternalRegex.OutputVectorSize] : new uint[InternalRegex.OutputVectorSize]; var match = InternalRegex.CreateRefMatch(outputVector); match.FirstMatch(subject, PcreMatchSettings.Default, startIndex); return(match.Success); }
public PcreRefMatch Match(ReadOnlySpan <char> subject, PcreMatchSettings settings) { if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.StartIndex < 0 || settings.StartIndex > subject.Length) { throw new IndexOutOfRangeException("Invalid StartIndex value"); } var match = InternalRegex.CreateRefMatch(); match.FirstMatch(subject, settings, settings.StartIndex); return(match); }
public PcreMatch Match(string subject, PcreMatchSettings settings) { if (subject == null) { throw new ArgumentNullException(nameof(subject)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (settings.StartIndex < 0 || settings.StartIndex > subject.Length) { throw new IndexOutOfRangeException("Invalid StartIndex value"); } return(InternalRegex.Match(subject, settings, settings.StartIndex, settings.AdditionalOptions.ToPatternOptions())); }
internal PcreCallout(string subject, InternalRegex regex, Native.pcre2_callout_block *callout) { _subject = subject; _regex = regex; _flags = callout->callout_flags; Number = (int)callout->callout_number; StartOffset = (int)callout->start_match; CurrentOffset = (int)callout->current_position; MaxCapture = (int)callout->capture_top; LastCapture = (int)callout->capture_last; PatternPosition = (int)callout->pattern_position; NextPatternItemLength = (int)callout->next_item_length; _markPtr = callout->mark; _oVector = new uint[callout->capture_top * 2]; _oVector[0] = (uint)callout->start_match; _oVector[1] = (uint)callout->current_position; for (var i = 2; i < _oVector.Length; ++i) { _oVector[i] = callout->offset_vector[i].ToUInt32(); } }
internal PcreDfaRegex(InternalRegex regex) { _regex = regex; }
internal PcrePatternInfo(InternalRegex re) { _re = re; }
internal RefMatchEnumerable(InternalRegex regex, ReadOnlySpan <char> subject, PcreMatchSettings settings) { _regex = regex; _subject = subject; _settings = settings; }