How to use the regexp-tree.parse function in regexp-tree

To help you get started, we’ve selected a few regexp-tree examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sverweij / dependency-cruiser / src / utl / safe-regex.js View on Github external
function pryRegExASTFromInput(pRegEx) {
  let lRegExp = null;

  if (pRegEx instanceof RegExp) {
    lRegExp = pRegEx;
  } else if (typeof pRegEx === "string") {
    lRegExp = new RegExp(pRegEx);
  } else {
    lRegExp = new RegExp(String(pRegEx));
  }

  // Build an AST
  return regexpTree.parse(lRegExp);
}