String#trim(chars)

Jordan Harband ljharb at gmail.com
Sat Apr 22 18:26:18 UTC 2017


So you want `'\t Test \n\n'.replace(/^[ \t\n]+|[ \t\n]+$/g, '') === 'Test'`?

On Sat, Apr 22, 2017 at 6:41 AM, Cyril Auburtin <cyril.auburtin at gmail.com>
wrote:

> Like some other languages (ex: python .strip, postgresql trim, ..) I think
> it would really useful that `String.prototype.trim` accept a string
> argument representing the characters to trim (or possible a regex).
>
> And keep it's default behavior if no argument is passed
>
> ```js
> '\t Test \n\n'.trim(' \t\n') == 'Test'
> ```
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20170422/4bcb3c2f/attachment.html>


More information about the es-discuss mailing list