Menu

gitpiper

cloneRegExp javascript Code Snippet in 2024

typeintermediate

Last Updated: 24 March 2024

Clones a regular expression.

  • Use new RegExp(), RegExp.prototype.source and RegExp.prototype.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

javascript snippet similar to cloneRegExp For You in March 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️