So I've been playing around with the replace function (开发者_JAVA百科method?) in js.
$get('msgBar').replace(/+/g,' ');
Let's say the content of $get('msgBar') is "Welcome+back+now".
replace('+',' ') would only replace the first +, and not the second.
replace(/+/g,' ') crashes
replace(/"+"/g,' ') and replace(/\+/g,' ') are both the same as the first
I'm sure the solution is easy... :)
You must quote +:
$get('msgBar').replace(/\+/g,' ');
'+' is a meta character, like '*'. It means "one more repetitions". It you literally want '+' , then you have to quote it with the backslash.
加载中,请稍侯......
精彩评论