// 已知条件let name ="人生得意须(),莫使金樽空()"let newArr =['尽欢|金环','对月|对越']let ShowAnswer ='尽欢|对月'// 答案let pattern =/()/gi;let arr = name .match(pattern);// 正则获取小括号形成数组for(let i =0; i < arr.length; i++){
name = name .replace(arr[i],`(@${i})`)// 循环重新字符串赋值}let Count = newArr.length;for(let i =0; i < Count; i++){
name = name .replace(`(@${i})`,` (${newArr[i].split('|').join(' ')})`)// 替换小括号中填答案}
console.log(name )return name
}