escape-string-regexp

Escape RegExp 特殊字符。「Escape RegExp special characters」

Github星跟踪图

escape-string-regexp

Escape RegExp special characters

Install

$ npm install escape-string-regexp

Usage

import escapeStringRegexp from 'escape-string-regexp';

const escapedString = escapeStringRegexp('How much $ for a 🦄?');
//=> 'How much \\$ for a 🦄\\?'

new RegExp(escapedString);

You can also use this to escape a string that is inserted into the middle of a regex, for example, into a character class.


主要指标

概览
名称与所有者sindresorhus/escape-string-regexp
主编程语言JavaScript
编程语言JavaScript (语言数: 2)
平台
许可证MIT License
所有者活动
创建于2014-06-24 15:04:40
推送于2025-05-06 15:42:08
最后一次提交
发布数10
最新版本名称v5.0.0 (发布于 2021-04-17 22:45:39)
第一版名称v1.0.0 (发布于 2014-06-24 17:06:42)
用户参与
星数594
关注者数13
派生数54
提交数33
已启用问题?
问题数28
打开的问题数0
拉请求数6
打开的拉请求数0
关闭的拉请求数7
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?