示例#1
0
        public static PatternMatch?GetFirstMatch(this PatternMatcher matcher, string candidate)
        {
            using var _ = ArrayBuilder <PatternMatch> .GetInstance(out var matches);

            matcher.AddMatches(candidate, matches);
            return(matches.Any() ? (PatternMatch?)matches.First() : null);
        }
示例#2
0
        public static PatternMatch?GetFirstMatch(this PatternMatcher matcher, string candidate)
        {
            var matches = ArrayBuilder <PatternMatch> .GetInstance();

            matcher.AddMatches(candidate, matches);

            var result = matches.FirstOrNullable();

            matches.Free();

            return(result);
        }
 public static PatternMatch?GetFirstMatch(this PatternMatcher matcher, string candidate)
 {
     using var matches = TemporaryArray <PatternMatch> .Empty;
     matcher.AddMatches(candidate, ref matches.AsRef());
     return(matches.Count > 0 ? matches[0] : null);
 }