Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

Functions

Object literals

Variables

Const alpha

alpha: (...args: A) => R = repeat.bind(null, matchers.ALPHA)

Equivalent to repeat.bind(null, '[A-z]')

Type declaration

    • (...args: A): R
    • Parameters

      • Rest ...args: A

      Returns R

Const numeric

numeric: (...args: A) => R = repeat.bind(null, matchers.NUMBER)

Equivalent to repeat.bind(null, '\\d')

Type declaration

    • (...args: A): R
    • Parameters

      • Rest ...args: A

      Returns R

Functions

and

  • and(...patterns: string[]): string
  • and('a', 'b', 'c') // -> 'abc'

    Parameters

    • Rest ...patterns: string[]

    Returns string

capture

  • capture(text: string, name?: string): string
  • capture('\\d+?') // -> (\\d+?)

    or you can name your capture group with capture(pattern, name)

    capture('\\d+?', 'number') // -> (?<number>\\d+?)

    Parameters

    • text: string
    • Optional name: string

    Returns string

extra

  • extra(text: string, isLazy?: boolean): string
  • extra('.', matchers.LAZY) // -> '.+?'
    extra('.', false) // -> '.+'

    Parameters

    • text: string
    • Default value isLazy: boolean = false

    Returns string

group

  • group(text: string): string
  • Similar to a capture(...), but won't keep the capture within the parentheses

    group('.|\\s') // -> (?:.|\\s)

    Parameters

    • text: string

    Returns string

or

  • or(...patterns: string[]): string
  • or('a', 'b', 'c') // -> 'a|b|c'

    Parameters

    • Rest ...patterns: string[]

    Returns string

regex

  • regex(pattern: string | RegExp, flag?: string): RegExp
  • Equal to RegExp() constructor

    Parameters

    • pattern: string | RegExp
    • Optional flag: string

    Returns RegExp

repeat

  • repeat(text: string, start?: number, end?: number): string
  • ```js repeat('\d') // -> \d repeat('\d', 8) // -> \d{8} repeat('\d', 1, 3) // -> \d{1,3} repeat('\d', 1, Infinity) // -> \d{1,}

    Parameters

    • text: string
    • Optional start: number
    • Optional end: number

    Returns string

whole

  • whole(text: string): string
  • whole('sentence to match') // -> ^sentence to match$

    Parameters

    • text: string

    Returns string

wildcard

  • wildcard(text: string, isLazy?: boolean): string
  • wildcard('.') // -> '.*'
    wildcard('.', true) // -> '.*?'

    Parameters

    • text: string
    • Default value isLazy: boolean = false

    Returns string

Object literals

Const flags

flags: object

GLOBAL

GLOBAL: string = "g"

INSENSITIVE

INSENSITIVE: string = "i"

MULTI_LINE

MULTI_LINE: string = "m"

STICKY

STICKY: string = "y"

UNICODE

UNICODE: string = "u"

Const look

look: object
look.ahead.positive('Y') === look.ahead('Y') // -> '(?=y)'
look.ahead.negative('Y') // -> '(?!y)'
look.behind.positive('Y') === look.behind('Y') // -> '(?<=y)'
look.behind.negative('Y') // -> '(?<!y)'

ahead

ahead: (Anonymous function) & { negative: (Anonymous function); positive: (Anonymous function) } = looker(false)

behind

behind: (Anonymous function) & { negative: (Anonymous function); positive: (Anonymous function) } = looker(true)

Const matchers

matchers: object

ALL

ALL: string = capture(or('.', '\\s'))

ALPHA

ALPHA: string = "[A-z]"

ANY

ANY: string = "."

END

END: string = "$"

GROUP

GROUP: string = "?:"

LAZY

LAZY: string = "?"

NUMBER

NUMBER: string = "\d"

START

START: string = "^"

WHITE_SPACE

WHITE_SPACE: string = "\s"

WORD

WORD: string = "\w"

not

not: object

Matches opposite of matchers

regex(matchers.not.ALPHA) // -> '[^A-z]'

ALPHA

ALPHA: string = "[^A-z]"

NUMBER

NUMBER: string = "\D"

WHITE_SPACE

WHITE_SPACE: string = "\S"

WORD

WORD: string = "\W"

Legend

  • Object literal
  • Variable
  • Function

Generated using TypeDoc