发布于 2023-10-10 14:44:49 浏览 559 次
var str = "Hello, my name is John Doe";var regex = /(John) (Doe)/;var newStr = str.replace(regex, "$2, $1");console.log(newStr);