Skip to main content
Module

std/path/mod.ts>globToRegExp

Deno standard library
Go to Latest
function globToRegExp
import { globToRegExp } from "https://deno.land/std@0.65.0/path/mod.ts";

Convert a glob string to a regular expressions.

 // 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"), {
     extended: true,
     globstar: true
   })]
 });

Parameters

glob: string
optional
unnamed 1: GlobToRegExpOptions = [UNSUPPORTED]

Returns

RegExp