在一个变量中,我有一个字符串值“农业和发展”。我想去掉字符串“农业和发展”中的空格和字符“&”,这样它看起来就像是使用jquery或javascript的Agriculture_Development。
发布于 2012-07-06 15:00:08
这里不需要jquery,简单的js就可以了:
var nwstr = 'Agriculture & Development'
.replace(/\s+/g,'')
.replace(/\&/,'_');
//=> Agriculture_Development
现在你自己来go and figure吧
发布于 2012-07-06 15:03:04
var str = "Agriculture & Development";
// replace all the white space and the &
str.replace(/\s+/g, '').replace(/\&/,'_');
https://stackoverflow.com/questions/11357310
复制相似问题