regular expression used in $.trim()
Hi Folks,
$.trim() uses the following RegExp to trim:
example link to jsbin because I can't insert backslashes ?
As it turns out, this can be pretty ugly, Example:
- var mystr = ' some test -- more text new test xxx';
Executing the rtrim RegExp to this string hangs Firefox and Chrome, it just takes like forever. "mystr" contains whitespaces but mostly hex 160(A0) characters. This "problem" does only occur, if there is no prepending whitespace/A0, but somewhere within the string. I have no clue why this happens.
This expression:
example link to jsbin because I can't insert backslashes ?
just works fine in all tested scenarios. Maybe a better pattern for that?
Kind Regards
Andreas
Update:
It looks like you can't copy&paste this example string, at some points those A0
characters are replaced.Firebug console
will also replace the characters on pasting, you have to create your own string in a sepperate html file/editor to test this.