Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
opts.strictOpen = false;
opts.strictClose = false;
}
var open = opts.strictOpen !== false ? '^' : '';
var close = opts.strictClose !== false ? '$' : '';
var flags = opts.flags || '';
var regex;
if (opts.nocase === true && !/i/.test(flags)) {
flags += 'i';
}
try {
if (opts.negate || typeof opts.strictNegate === 'boolean') {
pattern = not.create(pattern, opts);
}
var str = open + '(?:' + pattern + ')' + close;
regex = new RegExp(str, flags);
if (opts.safe === true && safe(regex) === false) {
throw new Error('potentially unsafe regular expression: ' + regex.source);
}
} catch (err) {
if (opts.strictErrors === true || opts.safe === true) {
err.key = key;
err.pattern = pattern;
err.originalOptions = options;
err.createdOptions = opts;
throw err;
opts.strictOpen = false;
opts.strictClose = false;
}
var open = opts.strictOpen !== false ? '^' : '';
var close = opts.strictClose !== false ? '$' : '';
var flags = opts.flags || '';
var regex;
if (opts.nocase === true && !/i/.test(flags)) {
flags += 'i';
}
try {
if (opts.negate || typeof opts.strictNegate === 'boolean') {
pattern = not.create(pattern, opts);
}
var str = open + '(?:' + pattern + ')' + close;
regex = new RegExp(str, flags);
if (opts.safe === true && safe(regex) === false) {
throw new Error('potentially unsafe regular expression: ' + regex.source);
}
} catch (err) {
if (opts.strictErrors === true || opts.safe === true) {
err.key = key;
err.pattern = pattern;
err.originalOptions = options;
err.createdOptions = opts;
throw err;
function textRegex(pattern) {
var notStr = regexNot.create(pattern, {contains: true, strictClose: false});
var prefix = '(?:[\\^]|\\\\|';
return toRegex(prefix + notStr + ')', {strictClose: false});
}
function createTextRegex(pattern) {
if (cached) return cached;
const opts = {contains: true, strictClose: false};
const not = regexNot.create(pattern, opts);
const re = toRegex('^(?:[*]\\((?=.)|' + not + ')', opts);
return (cached = re);
}
function createTextRegex(pattern) {
if (cached) return cached;
var opts = {contains: true, strictClose: false};
var not = regexNot.create(pattern, opts);
var re = toRegex('^(?:[*]\\((?=.)|' + not + ')', opts);
return (cached = re);
}
function createTextRegex(pattern) {
if (cached) return cached;
var opts = {contains: true, strictClose: false};
var not = regexNot.create(pattern, opts);
var re = toRegex('^(?:[*]\\((?=.)|' + not + ')', opts);
return (cached = re);
}
function createTextRegex(pattern) {
if (cached) return cached;
var opts = {contains: true, strictClose: false};
var not = regexNot.create(pattern, opts);
var re = toRegex('^(?:[*]\\((?=.)|' + not + ')', opts);
return (cached = re);
}