readable-regexp
TypeDocGitHubnpm
  • readable-regexp
  • Getting Started
    • Installation
    • Usage
  • API Reference
    • Character Classes
    • Anchors
    • Special Tokens
    • Quantifiers
    • Groups
    • Extras
    • TypeDoc
  • Custom Extensions
    • Custom Tokens
      • Step 1: Type Definition
      • Step 2: Implementation
      • Step 3: Usage
Powered by GitBook
On this page
  1. API Reference

Quantifiers

Function
RegExp equivalent
Explanation

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

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

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

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

(?:foo){3,5}?

Same as repeat, but match as short as possible

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

(?:foo){3,}

Match a token at least the specified amount of times.

atLeastLazily(3)`foo` atLeast.lazily(3)`foo`

(?:foo){3,}?

Same as atLeast, but match as short as possible

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

(?:foo){0,3}

Match a token at most the specified amount of times.

atMostLazily(3)`foo` atMost.lazily(3)`foo`

(?:foo){0,3}?

Same as atMost, but match as short as possible

maybe`foo` maybe.exactly`foo` maybe('foo')

(?:foo)?

Match a token 0 or 1 times

maybeLazily`foo` maybe.lazily`foo`

(?:foo)??

Same as maybe, but match as short as possible

zeroOrMore`foo` zeroOrMore.exactly`foo` zeroOrMore('foo')

(?:foo)*

Match a token 0 to infinite times

zeroOrMoreLazily`foo` zeroOrMore.lazily`foo`

(?:foo)*?

Same as zeroOrMore, but match as short as possible

oneOrMore`foo` oneOrMore.exactly`foo` oneOrMore('foo')

(?:foo)+

Match a token 1 to infinite times

oneOrMoreLazily`foo` oneOrMore.lazily`foo`

(?:foo)+?

Same as oneOrMore, but match as short as possible

PreviousSpecial TokensNextGroups

Last updated 1 year ago