var st = "Dream Theater A Change of Seasons (EP) (1995)";
var searchTerm = st.replace("/[\s\W]+/g", "+");
给出
梦剧场四季更替 EP 1995
但我想成为
梦想+剧院+A+Change+of+Seasons+EP+1995+
最佳答案
您需要:
var searchTerm = st.replace(/[\s\W]+/g, "+");
不带引号。
关于javascript正则表达式替换非单词和空格不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9674588/