SyntaxFix
Write A Post
Hire A Developer
Questions
expanding on @leaf 's answer, here's one that can take multiple characters:
var trim = function (s, t) { var tr, sr tr = t.split('').map(e => `\\\\${e}`).join('') sr = s.replace(new RegExp(`^[${tr}]+|[${tr}]+$`, 'g'), '') return sr }