该函数应将输入值转换为查询:
1. " bald valves " to "bald+valves"
2. " buffers some " to "buffers+some"
这是我目前的解决方案:
query.trim().replace(/\s\s+/g, ' ').replace(/[\s.;,?%]/, '+')
你能帮我改进吗?
答案 0 :(得分:0)
怎么样
s.trim().replace(/\s+/g,'+')
" bald valves ".trim().replace(/\s+/g,'+')
"bald+valves"
" buffers some ".trim().replace(/\s+/g,'+')
"buffers+some"