Bru*_*oLM 2 javascript string replace
我有一个由参数传递的字符串,我必须在另一个字符串中替换所有出现的字符串,例如:
function r(text, oldChar, newChar)
{
return text.replace(oldChar, newChar); // , "g")
}
Run Code Online (Sandbox Code Playgroud)
通过该字符可以是任何字符,包括^,|,$,[,],(,)...
有没有一种方法可以替换,例如,所有^来自字符串I ^like^ potatoes的$?
| 归档时间: |
|
| 查看次数: |
1304 次 |
| 最近记录: |