Function maybe

  • Match a token 0 or 1 times.

    Parameters

    • literal: string

    Returns RegExpToken

    Example

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

    RegExp equivalent:

    /(?:foo)?/
    

    Example

    Lazy matching

    maybeLazily`foo`
    maybe.lazily`foo`

    RegExp equivalent:

    /(?:foo)??/
    
  • Match a token 0 or 1 times.

    Parameters

    • template: TemplateStringsArray
    • Rest ...args: unknown[]

    Returns RegExpToken

    Example

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

    RegExp equivalent:

    /(?:foo)?/
    

    Example

    Lazy matching

    maybeLazily`foo`
    maybe.lazily`foo`

    RegExp equivalent:

    /(?:foo)??/
    
  • Match a token 0 or 1 times.

    Parameters

    Returns RegExpToken

    Example

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

    RegExp equivalent:

    /(?:foo)?/
    

    Example

    Lazy matching

    maybeLazily`foo`
    maybe.lazily`foo`

    RegExp equivalent:

    /(?:foo)??/
    

Generated using TypeDoc