Envelope 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

    • Creates a new Quantifier.

      Parameters

      • interval: Interval

        The interval defining how many times to match

      • Optionalreluctance: Reluctance

        The matching strategy (default: Greedy)

      Returns Quantifier

    Methods

    • Creates a quantifier from min/max values.

      Parameters

      • min: number

        Minimum occurrences

      • Optionalmax: number

        Maximum occurrences (undefined for unbounded)

      • Optionalreluctance: Reluctance

        The matching strategy

      Returns Quantifier

    • Creates a quantifier for exactly n occurrences.

      Parameters

      Returns Quantifier

    • Creates a quantifier for at least n occurrences.

      Parameters

      Returns Quantifier

    • Creates a quantifier for at most n occurrences.

      Parameters

      Returns Quantifier

    • Creates a quantifier for between min and max occurrences.

      Parameters

      • min: number
      • max: number
      • Optionalreluctance: Reluctance

      Returns Quantifier

    • Creates a quantifier for zero or more occurrences (*).

      Parameters

      Returns Quantifier

    • Creates a quantifier for one or more occurrences (+).

      Parameters

      Returns Quantifier

    • Creates a quantifier for zero or one occurrence (?).

      Parameters

      Returns Quantifier

    • Returns the minimum number of occurrences.

      Returns number

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

      Returns number | undefined

    • Returns the interval.

      Returns Interval

    • Returns the reluctance (matching strategy).

      Returns Reluctance

    • 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}"
    • Checks equality with another Quantifier.

      Parameters

      Returns boolean

    • Converts to an Interval (discarding reluctance).

      Returns Interval