Mmm.. I think space replacing doesn't deal (at all?) with trimming. When I'm programming with a language X and I need to trim I search for a function that does that job, when I need to strip away spaces I usually replace that character with an empty string.
If we like the smallest size possible for jquery.js then I think this would be the last thing we have to put into. d On Thu, Jul 9, 2009 at 5:26 PM, dotnetCarpenter<jon.ronnenb...@gmail.com> wrote: > > Hi all, > > I've submitted Ticket #4848 (new enhancement) about a week ago and > would like to hear what you guys think. I think it's handy for > telephone numbers, bank accounts (IBAN/SWIFT) ect. I realize that > changing the core API (no regression) requires some merit. Am I the > only one who like this idea? > > /** > * Uses a regular expression to remove whitespace from the given > string. > * @param {String} text The string to trim. > * @param {Boolean} [all] True to remove all white-space from the > text. > * @return {String} > */ > trim: function(text, all) { > var reg = all===true ? /\s+/g : /^\s+|\s+$/g; > return (text || "").replace(reg, ''); > } > > Cheers, Jon. > > PS. noticed a post back in november 2008 about optimizing the trim > method but don't know what the conclusion was. > > > > -- «I ka 'ôlelo nôke ola, I ka 'ôlelo nôka make» --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---