src/AvValidator/pattern.js
function asRegExp(pattern) {
  // if regex then return it
  if (isRegExp(pattern)) {
    return pattern;
  }

  // if string then test for valid regex then convert to regex and return
  const match = pattern.match(REGEX);
  if (match) {
    return new RegExp(match[1], match[2]);
  }

  return new RegExp(pattern);
}
function asRegExp(pattern) {
  // if regex then return it
  if (isRegExp(pattern)) {
    return pattern;
  }

  // if string then test for valid regex then convert to regex and return
  const match = pattern.match(REGEX);
  if (match) {
    return new RegExp(match[1], match[2]);
  }

  return new RegExp(pattern);
}
function asRegExp ( pattern ) { // if regex then return it if ( isRegExp ( pattern ) ) { return pattern ; } // if string then test for valid regex then convert to regex and return const match = pattern . match ( REGEX ) ; if ( match ) { return new RegExp ( match [ 1 ] , match [ 2 ] ) ; } return new RegExp ( pattern ) ; }
regular expression to test a regular expression
regular expression to test a regular expression