Skip to main content
Module

x/escape_string_regexp/mod.ts

Escape RegExp special characters
Latest
File
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.const matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
export function escapeStringRegexp(str: string): string { return str.replace(matchOperatorsRe, '\\$&');}