Function repeat

  • Match a token the specified amount of times. Supply 1 parameter for an exact number of times, or 2 parameters for min/max.

    Parameters

    • min: number
    • Optional max: number

    Returns LiteralFunction & TokenFunction & RegExpToken

    Example

    2 parameters for min/max

    repeat(3,5)`foo`
    repeat(3,5).exactly`foo`
    repeat(3,5)('foo')

    RegExp equivalent:

    /(?:foo){3,5}/
    

    Example

    1 parameter for exact number

    repeat(3)`foo`
    repeat(3).exactly`foo`
    repeat(3)('foo')

    RegExp equivalent:

    /(?:foo){3}/
    

    Example

    Lazy matching

    repeatLazily(3,5)`foo`
    repeat.lazily(3,5)`foo`

    RegExp equivalent:

    /(?:foo){3,5}?/
    

Generated using TypeDoc