trim()和“& nbsp;” [英] trim() and " "
本文介绍了trim()和“& nbsp;”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我使用以下修剪功能:
功能修剪(str){
返回str.replace(/ ^ \ s * / g,'''').replace(/ \ * * $ / g,'''');
}
问题是这并没有削减& nbsp;的实例。 char -
不间断的空间。这可以用
的grep声明表示吗?
Rob
:)
Hi All,
I am using the following trim function:
function trim (str) {
return str.replace(/^\s*/g, '''').replace(/\s*$/g, '''');
}
The problem is that this doesn''t trim instances of the " " char -
the non breaking space. Can this be represented in a grep statement at
all?
Rob
:)
推荐答案
/ g,'''');
}
问题是这并没有削减& nbsp;的实例。 char -
不间断的空间。这可以用
的grep声明表示吗?
Rob
:)
/g, '''');
}
The problem is that this doesn''t trim instances of the " " char -
the non breaking space. Can this be represented in a grep statement at
all?
Rob
:)
Robert Mark Bram写道:
Robert Mark Bram wrote:
大家好,
我正在使用以下修剪功能:
> function trim(str){
return str.replace(/ ^ \s * / g,'''').replace(/ \ * *
Hi All,
I am using the following trim function:
function trim (str) {
return str.replace(/^\s*/g, '''').replace(/\s*
/ G, '''');
并不是说我能说出任何实际的区别,但
不应该是一个或多个匹配,而不是零或更多?
返回str.replace(/ ^ \s + / g,'''').replace(/ \s +
/g, '''');
Not that it makes any practical difference that I can tell, but
shouldn''t the match be for one or more, not zero or more?
return str.replace(/^\s+/g, '''').replace(/\s+
这篇关于trim()和“& nbsp;”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文