【问题标题】:replacing all occurrences of a space character替换所有出现的空格字符
【发布时间】:2013-03-07 14:24:15
【问题描述】:

我正在寻找替换空格(非中断空格)的解决方案。
这是我尝试过的:

     var text = this.get('text').toLowerCase().replace(' ','');

但它没有按预期工作,并且没有替换所有空格。
如果相关,我正在使用 MooTools。

【问题讨论】:

    标签: text replace mootools


    【解决方案1】:

    Mootools replace 仅替换第一个实例,除非您使用带有全局修饰符的正则表达式。试试这个吧。

    var text = this.get('text').toLowerCase().replace(/\s/g,'');
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-22
      • 2012-01-31
      • 1970-01-01
      • 2019-01-10
      • 2018-07-11
      • 2018-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多