Can someone help me understand this commit
What is \u00A0 ?
The code strips trailing and leading space characters in addition to non breaking spaces, \u00A0 is the unicode point/code/number/alias for the non breaking space. You can pop up Firebug and type it out.
>>> '\u00A0'
" "
Further information about this character:
http://www.fileformat.info/info/unicode/char/00a0/index.htm
Edit: I just tried this code in Firebug, which checks for any matches from the generated non breaking space and it matched:
javascript:alert( String.fromCharCode(160).match(/\s/) )
However, upon doing this in IE6 it returns null, so IE is most likely the reason for this update.
Update #2 - it looks like the removal of the caret makes this inconsistent with the previous version, because it removes not just leading and trailing spaces but spaces anywhere.
r = /(\s|\u00A0)+|(\s|\u00A0)+$/g;
s = ' wh at'
s = s.replace( r, '' )
Outputs
"what"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With