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.

index.js 320B

12345678910
  1. 'use strict';
  2. var escapeStringRegexp = require('escape-string-regexp');
  3. module.exports = function (str, target) {
  4. if (typeof str !== 'string' || typeof target !== 'string') {
  5. throw new TypeError('Expected a string');
  6. }
  7. return str.replace(new RegExp('(?:' + escapeStringRegexp(target) + '){2,}', 'g'), target);
  8. };