mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Bump to v3.10.0.
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import baseToString from '../internal/baseToString';
|
||||
import escapeRegExpChar from '../internal/escapeRegExpChar';
|
||||
|
||||
/**
|
||||
* Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special).
|
||||
* In addition to special characters the forward slash is escaped to allow for
|
||||
* easier `eval` use and `Function` compilation.
|
||||
* Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns)
|
||||
* and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern).
|
||||
*/
|
||||
var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
|
||||
var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g,
|
||||
reHasRegExpChars = RegExp(reRegExpChars.source);
|
||||
|
||||
/**
|
||||
@@ -25,8 +25,8 @@ var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
|
||||
function escapeRegExp(string) {
|
||||
string = baseToString(string);
|
||||
return (string && reHasRegExpChars.test(string))
|
||||
? string.replace(reRegExpChars, '\\$&')
|
||||
: string;
|
||||
? string.replace(reRegExpChars, escapeRegExpChar)
|
||||
: (string || '(?:)');
|
||||
}
|
||||
|
||||
export default escapeRegExp;
|
||||
|
||||
Reference in New Issue
Block a user