It's not uncommon that I have to trim strings in my projects. Since the trim method on the String object is not generally available on all browser platforms I've decided to extend JSMCV's $.String class a bit:
- steal(
- 'jquery',
- 'jquery/lang/string'
- ).then(function($) {
- $.extend(true, $.String, {
- trim: function (s) { return s.replace(/^\s+|\s+$/g, ''); },
- ltrim: function (s) { return s.replace(/^\s+/, ''); },
- rtrim: function (s) { return s.replace(/\s+$/, ''); }
- });
- });
I wonder if this could be added to the $.String object in some future version?
--
Thomas