Added cloneRegExp
This commit is contained in:
14
snippets/cloneRegExp.md
Normal file
14
snippets/cloneRegExp.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
### cloneRegExp
|
||||||
|
|
||||||
|
Clones a regular expression.
|
||||||
|
|
||||||
|
Use `new RegExp()`, `RegExp.source` and `RegExp.flags` to clone the given regular expression.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
const regExp = /lorem ipsum/gi;
|
||||||
|
const regExp2 = cloneRegExp(regExp); // /lorem ipsum/gi
|
||||||
|
```
|
||||||
@ -10,6 +10,7 @@ chainAsync:function
|
|||||||
chunk:array
|
chunk:array
|
||||||
clampNumber:math
|
clampNumber:math
|
||||||
cleanObj:object
|
cleanObj:object
|
||||||
|
cloneRegExp:utility
|
||||||
coalesce:utility
|
coalesce:utility
|
||||||
coalesceFactory:utility
|
coalesceFactory:utility
|
||||||
collatz:math
|
collatz:math
|
||||||
|
|||||||
Reference in New Issue
Block a user