Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

globrex

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

globrex

Glob to regular expression with support for extended globs

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is globrex?

The globrex npm package is designed to convert glob expressions into regular expressions. This allows for matching strings against complex patterns, commonly used for file matching in file systems. It supports a wide range of glob patterns, including wildcards, choice groups, and negated patterns.

What are globrex's main functionalities?

Convert glob to regex

This feature allows you to convert a simple glob pattern, like '*.js', into its equivalent regular expression. This is useful for matching filenames or strings that end with '.js'.

const globrex = require('globrex');
const { regex } = globrex('*.js');
console.log(regex); // Outputs the regex equivalent of the '*.js' glob pattern

Extended glob patterns

Globrex supports extended glob patterns, such as negated patterns using '!(pattern)'. This example demonstrates converting a negated glob pattern into a regex, which matches any '.js' file that does not start with 'pattern' or 'pattern2'.

const globrex = require('globrex');
const { regex } = globrex('!(pattern|pattern2)*.js');
console.log(regex); // Outputs the regex for negated patterns

Path mode

In path mode, with 'globstar' option enabled, globrex can convert glob patterns that match files in a directory and its subdirectories. This is particularly useful for file system operations where you need to match files across multiple directories.

const globrex = require('globrex');
const { regex } = globrex('path/**/*.js', { globstar: true });
console.log(regex); // Outputs the regex for matching any '.js' file in the 'path' directory and its subdirectories

Other packages similar to globrex

Keywords

FAQs

Package last updated on 16 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc