mirror of
https://github.com/unarray/file-tree-generator.git
synced 2026-07-22 08:40:29 +00:00
Refactor regex utils
This commit is contained in:
parent
0807664519
commit
3a62bfb151
3 changed files with 10 additions and 3 deletions
|
|
@ -1 +1,2 @@
|
|||
export * from "./regex";
|
||||
export * from "./regex";
|
||||
export * from "./regex.util";
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
export const escapeString = (string: string): string => {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
||||
import { escapeString } from "./regex.util";
|
||||
|
||||
|
||||
export const beginningString = (string: string): RegExp => {
|
||||
return new RegExp(`^${escapeString(string)}`);
|
||||
};
|
||||
3
src/utils/regex/regex.util.ts
Normal file
3
src/utils/regex/regex.util.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
export const escapeString = (string: string): string => {
|
||||
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
||||
};
|
||||
Loading…
Reference in a new issue