✏️ 编辑:escapeRegExp.js
路径:
/home/boguraj1/public_html/jobsite/node_modules/lodash/escapeRegExp.js
大小:871 B · 修改:2022-11-21 20:09:48 · 权限:0644 · 可写
← 返回目录
👁 查看
⬇ 下载
var toString = require('./toString'); /** * Used to match `RegExp` * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns). */ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar.source); /** * Escapes the `RegExp` special characters "^", "$", "\", ".", "*", "+", * "?", "(", ")", "[", "]", "{", "}", and "|" in `string`. * * @static * @memberOf _ * @since 3.0.0 * @category String * @param {string} [string=''] The string to escape. * @returns {string} Returns the escaped string. * @example * * _.escapeRegExp('[lodash](https://lodash.com/)'); * // => '\[lodash\]\(https://lodash\.com/\)' */ function escapeRegExp(string) { string = toString(string); return (string && reHasRegExpChar.test(string)) ? string.replace(reRegExpChar, '\\$&') : string; } module.exports = escapeRegExp;
💾 保存
取消
保存为 UTF-8,换行统一为 LF