1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/utils/escapeRegExp.ts
Roman d050d6c0ea fix validation
Signed-off-by: Roman <ixrock@gmail.com>
2020-11-24 17:04:39 +02:00

6 lines
216 B
TypeScript

// Helper to sanitize / escape special chars for passing to RegExp-constructor
export function escapeRegExp(str: string) {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}