如 将 “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~