dCBOR Pattern TypeScript - v1.0.0-alpha.20
    Preparing search index...

    Class Quantifier

    Defines how many times a pattern may or must match, with an interval and a reluctance.

    // Zero or more, greedy
    const star = Quantifier.zeroOrMore();

    // One or more, lazy
    const plusLazy = Quantifier.oneOrMore(Reluctance.Lazy);

    // Exactly 3 times
    const exact = Quantifier.exactly(3);

    // Between 2 and 5, possessive
    const range = Quantifier.between(2, 5, Reluctance.Possessive);
    Index

    Constructors

    Methods

    • Creates a quantifier from min/max values.

      Parameters

      • min: number

        Minimum occurrences

      • Optionalmax: number

        Maximum occurrences (undefined for unbounded)

      • reluctance: Reluctance = DEFAULT_RELUCTANCE

        The matching strategy

      Returns Quantifier

    • Returns the minimum number of occurrences.

      Returns number

    • Returns the maximum number of occurrences, or undefined if unbounded.

      Returns number | undefined

    • Checks if the given count is within the quantifier's range.

      Parameters

      • count: number

      Returns boolean

    • Checks if the quantifier is unbounded (no maximum).

      Returns boolean

    • Returns a string representation of the quantifier.

      Returns string

      Quantifier.zeroOrMore().toString()              // "*"
      Quantifier.zeroOrMore(Reluctance.Lazy).toString() // "*?"
      Quantifier.between(1, 5).toString() // "{1,5}"