mirror of
https://github.com/wassname/talk.git
synced 2026-06-28 16:31:31 +08:00
11 lines
234 B
JavaScript
11 lines
234 B
JavaScript
/**
|
|
* Escape string for special regular expression characters.
|
|
*/
|
|
function escapeRegExp(string) {
|
|
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
}
|
|
|
|
module.exports = {
|
|
escapeRegExp,
|
|
};
|