以基字串中的取代字串取代所有符合目標字串的發生次數。
替換從字串的開頭到結尾,例如,將字串"aaa"中的"aa"取代為"b"將產生"ba"而非"ab"。
字串
replaceAll(<parameters>)
參數 | 類型 |
---|---|
基礎 | 字串 |
Target | 字串(RegExp) |
更換 | 字串 |
replaceAll(<baseString>,<sourceString>,<replacementString>)
傳回字串。
replaceAll("Hello World", "l", "x")
返回"Hexxo Worxd"。
由於目標參數為RegExp,因此根據您要取代的字串,您可能需要逸出某些字元。 請參閱 本頁.