Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20993
| From | "Joao Rodrigues (J.R.)" <groups_jr-1@yahoo.com.br> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: textarea multi-line regex |
| Date | 2013-08-19 11:04 -0300 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <kut8l8$fge$1@speranza.aioe.org> (permalink) |
| References | <kunrtr$bdr$1@dont-email.me> <520f7647$0$6638$9b4e6d93@newsspool2.arcor-online.net> <2064695.sT4V1ypfN8@PointedEars.de> |
Em 18/08/2013 05:57, Thomas 'PointedEars' Lahn escreveu:
> Martin Honnen wrote:
>> If you want to trim leading and trailing white space can't you simply use
>> string = string.replace(/^\s+|\s+$/g, '')
>
> string = string.replace(/^\s+/, '').replace(/\s+$/, '');
>
> might be more efficient:
>
> <http://blog.stevenlevithan.com/archives/faster-trim-javascript>
>
<snip>
>
> You may want to emulate the “trim” method if you cannot be sure it is
> implemented, and you need to trim more than one time:
>
> if (typeof String.prototype.trim != "function")
> {
> String.prototype.trim = function () {
> return this.replace(/^\s+/, '').replace(/\s+$/, '');
> };
> }
>
> // …
>
> string = string.trim();
>
> (Emulations backwards compatible to the earliest versions of ECMAScript
> implementations, and beyond, are also conceivable.)
>
>> ? See also http://jibbering.com/faq/#trimString.
>
> An update there is indicated.
Thomas, would please update the version in your site?
<http://pointedears.de/scripts/faq/cljs/#trimString>
--
Joao Rodrigues (J.R.)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
textarea multi-line regex Denis McMahon <denismfmcmahon@gmail.com> - 2013-08-17 12:56 +0000
Re: textarea multi-line regex Martin Honnen <mahotrash@yahoo.de> - 2013-08-17 15:10 +0200
Re: textarea multi-line regex "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-08-17 17:13 +0200
Re: textarea multi-line regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-18 10:57 +0200
Re: textarea multi-line regex "Joao Rodrigues (J.R.)" <groups_jr-1@yahoo.com.br> - 2013-08-19 11:04 -0300
Re: textarea multi-line regex Denis McMahon <denismfmcmahon@gmail.com> - 2013-08-17 13:18 +0000
Re: textarea multi-line regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-18 10:29 +0200
Re: textarea multi-line regex Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-08-18 19:24 +0100
Re: textarea multi-line regex "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-08-18 23:11 +0200
Re: textarea multi-line regex Denis McMahon <denismfmcmahon@gmail.com> - 2013-08-18 21:36 +0000
Re: textarea multi-line regex "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-08-19 00:50 +0200
Re: textarea multi-line regex Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-08-19 19:48 +0100
Re: textarea multi-line regex Stefan Weiss <krewecherl@gmail.com> - 2013-08-19 00:18 +0200
Re: textarea multi-line regex Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-08-18 10:22 +0200
csiph-web