【发布时间】:2014-06-03 04:13:30
【问题描述】:
所以我有一个配音
如果我有:
var string = "The String";
但我希望字符串总是看起来“字符串”(如果有多个序列,则只有 1 个空格)
如何以一种聪明的方式和动态地做到这一点,我的意思是有很多这样的情况:
string = "This String";
string = "This String is short";
string = "This is the string";
我在正则表达式方面完全是愚蠢的(不仅在它上面),我想这是唯一的方法吗?
【问题讨论】:
-
你考虑过用谷歌搜索
replace multiple spaces with one
标签: javascript string replace trim