mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Bump to v4.1.0.
This commit is contained in:
19
_cloneRegExp.js
Normal file
19
_cloneRegExp.js
Normal file
@@ -0,0 +1,19 @@
|
||||
/** 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 Ctor = regexp.constructor,
|
||||
result = new Ctor(regexp.source, reFlags.exec(regexp));
|
||||
|
||||
result.lastIndex = regexp.lastIndex;
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = cloneRegExp;
|
||||
Reference in New Issue
Block a user