如 将 “My name is xxx” 里面的所有空格转换为 “~”
let str="My name is xxx"; str=str.replace(/ /g,'~'); // My~name~is~xxx
如 将 “My name (is) xxx” 里面的所有括号转换为 “~”
let str = "My name (is) (xxx)" ; str = str.replace(/[()|()]/g,'~'); // My name ~is~ ~xxx~
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/202107.html原文链接:https://javaforall.net
