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.

17 regels
439 B

3 jaren geleden
  1. /** Used to match `RegExp` flags from their coerced string values. */
  2. var reFlags = /\w*$/;
  3. /**
  4. * Creates a clone of `regexp`.
  5. *
  6. * @private
  7. * @param {Object} regexp The regexp to clone.
  8. * @returns {Object} Returns the cloned regexp.
  9. */
  10. function cloneRegExp(regexp) {
  11. var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
  12. result.lastIndex = regexp.lastIndex;
  13. return result;
  14. }
  15. module.exports = cloneRegExp;