Files
lodash/_cloneRegExp.js
John-David Dalton 8166b65853 Bump to v4.6.0.
2016-02-29 23:38:21 -08:00

21 lines
488 B
JavaScript

define([], function() {
/** Used to match `RegExp` flags from their coerced string values. */
var reFlags = /\w*$/;
/**
* Creates a clone of `regexp`.
*
* @private
* @param {Object} regexp The regexp to clone.
* @returns {Object} Returns the cloned regexp.
*/
function cloneRegExp(regexp) {
var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
result.lastIndex = regexp.lastIndex;
return result;
}
return cloneRegExp;
});