Function ref

  • Supply a number to reference the capture group with that index. Supply a string to reference a named capture group.

    Parameters

    • literal: string

    Returns RegExpToken

    Example

    Named reference

    captureAs`name``foo`.ref`name`
    

    RegExp equivalent:

    /(?<name>foo)\k<name>/
    

    Example

    Number reference

    capture`foo`.ref(1)
    

    RegExp equivalent:

    /(foo)\1/
    
  • Supply a number to reference the capture group with that index. Supply a string to reference a named capture group.

    Parameters

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

    Returns RegExpToken

    Example

    Named reference

    captureAs`name``foo`.ref`name`
    

    RegExp equivalent:

    /(?<name>foo)\k<name>/
    

    Example

    Number reference

    capture`foo`.ref(1)
    

    RegExp equivalent:

    /(foo)\1/
    
  • Supply a number to reference the capture group with that index. Supply a string to reference a named capture group.

    Parameters

    • num: number

    Returns RegExpToken

    Example

    Named reference

    captureAs`name``foo`.ref`name`
    

    RegExp equivalent:

    /(?<name>foo)\k<name>/
    

    Example

    Number reference

    capture`foo`.ref(1)
    

    RegExp equivalent:

    /(foo)\1/
    

Generated using TypeDoc