Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 376 Bytes

cloneRegExp.md

File metadata and controls

17 lines (13 loc) · 376 Bytes
title tags
cloneRegExp
type,string,regexp,intermediate

Clones a regular expression.

  • Use new RegExp(), RegExp.source and RegExp.flags to clone the given regular expression.
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
const regExp = /lorem ipsum/gi;
const regExp2 = cloneRegExp(regExp); // regExp !== regExp2