public override int Match(MatchContent content)
        {
            var count = _inner.Match(content);

            if (count == NotMatch)
            {
                return(NotMatch);
            }
            var g = content.GetGroup(_groupName);

            if (g == null)
            {
                return(NotMatch);
            }
            switch (_comparsion)
            {
            case LengthComparison.Equals:
                return(count == g.Value.Count ? count : NotMatch);

            case LengthComparison.LessThan:
                return(count < g.Value.Count ? count : NotMatch);

            case LengthComparison.GreaterThan:
                return(count > g.Value.Count ? count : NotMatch);

            case LengthComparison.LessThanOrEquals:
                return(count <= g.Value.Count ? count : NotMatch);

            case LengthComparison.GreaterThanOrEquals:
                return(count >= g.Value.Count ? count : NotMatch);

            default:
                throw new InvalidOperationException();
            }
        }
Example #2
0
 public override int Match(MatchContent content)
 {
     if (content.EndOfString())
     {
         return(NotMatch);
     }
     return(content.GetCurrentChar() != _ch ? 1 : NotMatch);
 }
Example #3
0
 public override int Match(MatchContent content)
 {
     if (content.EndOfString())
     {
         return(NotMatch);
     }
     return(Array.BinarySearch(_ch, content.GetCurrentChar()) >= 0 ? 1 : NotMatch);
 }
Example #4
0
 /// <summary>
 /// Match string in content.
 /// </summary>
 /// <param name="content">The content.</param>
 /// <returns>Char count of match, <c>-1</c> is not match.</returns>
 public abstract int Match(MatchContent content);
 public MatchResult(int length, MatchContent mc)
 {
     Length = length;
     _mc    = mc;
 }