Interface RegExp

    interface RegExp {
        dotAll: boolean;
        flags: string;
        global: boolean;
        hasIndices: boolean;
        ignoreCase: boolean;
        lastIndex: number;
        multiline: boolean;
        source: string;
        sticky: boolean;
        unicode: boolean;
        [match](string: string): RegExpMatchArray;
        [matchAll](str: string): RegExpStringIterator<RegExpMatchArray>;
        [replace](string: string, replaceValue: string): string;
        [replace](string: string, replacer: ((substring: string, ...args: any[]) => string)): string;
        [search](string: string): number;
        [split](string: string, limit?: number): string[];
        compile(pattern: string, flags?: string): this;
        exec(string: string): RegExpExecArray;
        test(string: string): boolean;
    }

    Properties

    dotAll: boolean

    Returns a Boolean value indicating the state of the dotAll flag (s) used with a regular expression. Default is false. Read-only.

    flags: string

    Returns a string indicating the flags of the regular expression in question. This field is read-only. The characters in this string are sequenced and concatenated in the following order:

    • "g" for global
    • "i" for ignoreCase
    • "m" for multiline
    • "u" for unicode
    • "y" for sticky

    If no flags are set, the value is the empty string.

    global: boolean

    Returns a Boolean value indicating the state of the global flag (g) used with a regular expression. Default is false. Read-only.

    hasIndices: boolean

    Returns a Boolean value indicating the state of the hasIndices flag (d) used with a regular expression. Default is false. Read-only.

    ignoreCase: boolean

    Returns a Boolean value indicating the state of the ignoreCase flag (i) used with a regular expression. Default is false. Read-only.

    lastIndex: number
    multiline: boolean

    Returns a Boolean value indicating the state of the multiline flag (m) used with a regular expression. Default is false. Read-only.

    source: string

    Returns a copy of the text of the regular expression pattern. Read-only. The regExp argument is a Regular expression object. It can be a variable name or a literal.

    sticky: boolean

    Returns a Boolean value indicating the state of the sticky flag (y) used with a regular expression. Default is false. Read-only.

    unicode: boolean

    Returns a Boolean value indicating the state of the Unicode flag (u) used with a regular expression. Default is false. Read-only.

    Methods

    • Matches a string with this regular expression, and returns an array containing the results of that search.

      Parameters

      • string: string

        A string to search within.

      Returns RegExpMatchArray

    • Replaces text in a string, using this regular expression.

      Parameters

      • string: string

        A String object or string literal whose contents matching against this regular expression will be replaced

      • replaceValue: string

        A String object or string literal containing the text to replace for every successful match of this regular expression.

      Returns string

    • Replaces text in a string, using this regular expression.

      Parameters

      • string: string

        A String object or string literal whose contents matching against this regular expression will be replaced

      • replacer: ((substring: string, ...args: any[]) => string)

        A function that returns the replacement text.

          • (substring, ...args): string
          • Parameters

            • substring: string
            • Rest...args: any[]

            Returns string

      Returns string

    • Finds the position beginning first substring match in a regular expression search using this regular expression.

      Parameters

      • string: string

        The string to search within.

      Returns number

    • Returns an array of substrings that were delimited by strings in the original input that match against this regular expression.

      If the regular expression contains capturing parentheses, then each time this regular expression matches, the results (including any undefined results) of the capturing parentheses are spliced.

      Parameters

      • string: string

        string value to split

      • Optionallimit: number

        if not undefined, the output array is truncated so that it contains no more than 'limit' elements.

      Returns string[]

    • Parameters

      • pattern: string
      • Optionalflags: string

      Returns this

      A legacy feature for browser compatibility

    • Executes a search on a string using a regular expression pattern, and returns an array containing the results of that search.

      Parameters

      • string: string

        The String object or string literal on which to perform the search.

      Returns RegExpExecArray

    • Returns a Boolean value that indicates whether or not a pattern exists in a searched string.

      Parameters

      • string: string

        String on which to perform the search.

      Returns boolean