String#trim(chars)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

String#trim(chars)

Cyril Auburtin
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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: String#trim(chars)

Jordan Harband
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 <[hidden email]> 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
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss