You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
306 B

'use strict';
var escapeStringRegexp = require('escape-string-regexp');
module.exports = function (str, sub) {
if (typeof str !== 'string' || typeof sub !== 'string') {
throw new TypeError();
}
sub = escapeStringRegexp(sub);
return str.replace(new RegExp('^' + sub + '|' + sub + '$', 'g'), '');
};