以基礎字串中的取代字串取代符合目標字串的所有專案。
取代會從字串的開頭到結尾進行,例如,將字串「aaa」中的「aa」取代為「b」將會產生「ba」而不是「ab」。
字串
replaceAll(<parameters>)
參數 | 類型 |
---|---|
基底 | 字串 |
Target | 字串(RegExp) |
取代 | 字串 |
replaceAll(<baseString>,<sourceString>,<replacementString>)
傳回字串。
replaceAll("Hello World", "l", "x")
傳回「Hexxo Worxd」。
由於目標引數是RegExp,因此根據您要取代的字串,您可能需要逸出部分字元。 請參考中的範例 此頁面.