the number of possible parenthesized substrings is unlimited. The returned array holds all that were found. The following examples illustrate how to use parenthesized substring matches.
例如,/a(b)c/ 匹配字符 'abc' 並記住 'b'。 要調用這些帶括號的子字符串匹配項,請使用數組元素 [1], ..., [n]。
可能的括號子串的數量是無限的。 返回的數組包含所有找到的內容。
以下示例說明如何使用帶括號的子字符串匹配。
下面這個 script 以 replace() 方法移轉字串位置。對於要被置換的文字內容, 以 $1 和 $2 來代表先前 re 這個變數裡面,找出來綑綁且照順序來表示兩個子字串。