神岛 API 文档 - ArenaPro版
    Preparing search index...

    表示一个正则表达式对象。

    Represents a regular expression object.

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

    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.

    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

    下一次匹配开始的索引位置。

    The index at which to start the next match.

    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

    • Parameters

      • string: string

      Returns RegExpMatchArray

      匹配一个字符串与此正则表达式,并返回一个包含该搜索结果的数组。

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

      要搜索的字符串。

      A string to search within.

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

      Parameters

      • str: string

      Returns RegExpStringIterator<RegExpMatchArray>

    • Parameters

      • str: string

      Returns IterableIterator<RegExpMatchArray>

      使用此正则表达式匹配字符串,并返回一个包含该搜索结果的匹配项的可迭代对象。

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

      要在其中搜索的字符串。

      A string to search within.

    • 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.

      Returns string

    • Parameters

      • string: string
      • replaceValue: string

      Returns string

      使用此正则表达式替换字符串中的文本。

      Replaces text in a string, using this regular expression.

      将对其内容与此正则表达式进行匹配并替换的 String 对象或字符串字面量。

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

      一个 String 对象或字符串字面量,包含用于替换此正则表达式每次成功匹配的文本。

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

    • Parameters

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

      Returns string

      使用此正则表达式替换字符串中的文本。

      Replaces text in a string, using this regular expression.

      将对其内容与此正则表达式进行匹配并替换的 String 对象或字符串字面量。

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

      一个返回替换文本的函数。

      A function that returns the replacement text.

    • 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

    • Parameters

      • string: string

      Returns number

      使用此正则表达式在正则表达式搜索中查找第一个子字符串匹配的起始位置。

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

      要搜索的字符串。

      The string to search within.

      匹配的起始位置。

      The index of the start of the match.

    • 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

      • string: string
      • Optionallimit: number

      Returns string[]

      返回一个子字符串数组,这些子字符串由原始输入中与此正则表达式匹配的字符串分隔。

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

      要拆分的字符串。

      String to split.

      一个用于限制数组中返回元素数量的值。

      A value used to limit the number of elements returned in the array.

      一个包含子字符串的数组。

      An array of substrings.

    • Parameters

      • pattern: string
      • Optionalflags: string

      Returns this

      A legacy feature for browser compatibility

    • Returns this

      (非标准)编译正则表达式,使其执行更快。

      (Non-standard) Compiles a regular expression, making it execute faster.

    • 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

    • Parameters

      • string: string

      Returns RegExpExecArray

      使用正则表达式模式对字符串执行搜索,并返回包含该搜索结果的数组。

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

      要在其上执行搜索的 String 对象或字符串字面量。

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

    • 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

    • Parameters

      • string: string

      Returns boolean

      返回一个布尔值,指示模式是否存在于被搜索的字符串中。

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

      要在其上执行搜索的字符串。

      String on which to perform the search.