<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>title</title>
</head>
<body>
<script>
let str1 = '[旧,旧,旧,旧]'
let str2 = str1.replace(/(.*)旧/,'$1新'); //$1 + 替换后的字符
console.log("替换字符串中的最后一个匹配项:",str2)
</script>
</body>
</html>