Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/deno/std/path/mod.ts>globToRegExp

A modern runtime for JavaScript and TypeScript.
Go to Latest
function globToRegExp
import { globToRegExp } from "https://deno.land/x/deno@v0.22.0/std/path/mod.ts";

Generate a regex based on glob pattern and options This was meant to be using the the fs.walk function but can be used anywhere else. Examples:

Looking for all the `ts` files:
walkSync(".", {
  match: [globToRegExp("*.ts")]
})

Looking for all the `.json` files in any subfolder:
walkSync(".", {
  match: [globToRegExp(join("a", "**", "*.json"),{
    flags: "g",
    extended: true,
    globstar: true
  })]
})

Parameters

glob: string
  • Glob pattern to be used
optional
options: GlobToRegExpOptions = [UNSUPPORTED]
  • Specific options for the glob pattern

Returns

RegExp

A RegExp for the glob pattern