Key Facts
- Category
- Development
- Input Types
- text, checkbox, textarea
- Output Type
- json
- Sample Coverage
- 4
- API Ready
- Yes
Overview
This tool converts file matching patterns known as Glob into standard regular expressions. It supports features like brace expansion and recursive directory matching, enabling developers to create custom file matching logic for various programming contexts.
When to Use
- •When you need to use Glob patterns in systems or tools that require regular expressions for file matching.
- •To understand or debug complex Glob patterns by viewing their equivalent regex representation.
- •For building file filtering features in applications that only support regex-based matching.
How It Works
- •Enter a Glob pattern, such as 'src/**/*.ts', into the input field.
- •Configure options like enabling extended mode for brace expansion or globstar for recursive '**' support.
- •Optionally, add test strings to verify which paths the generated regex will match.
- •The tool outputs the corresponding regular expression ready for use in code or scripts.
Use Cases
Examples
1. Convert Basic Glob Pattern
- Background
- A developer needs to match all TypeScript files in a source directory for a build process.
- Problem
- The build system requires a regular expression, but the file pattern is specified in Glob format.
- How to Use
- Enter 'src/**/*.ts' in the Glob Pattern field and ensure globstar support is enabled.
- Outcome
- The tool outputs a regex that matches files like 'src/app/index.ts' and 'src/lib/utils.ts'.
2. Handle Brace Expansion
DevOps Engineer- Background
- Setting up a deployment script that processes configuration files with multiple extensions.
- Problem
- Need to convert a Glob pattern with braces to a regex for script integration.
- How to Use
- Input 'config/*.{json,yaml}' and check the Extended Mode option.
- Example Config
-
Extended mode enabled. - Outcome
- The generated regex matches both 'config/app.json' and 'config/settings.yaml' files.
3. Test Recursive Matching
- Background
- Verifying that a Glob pattern correctly matches files in nested directories for a file search feature.
- Problem
- Ensure the '**' wildcard works as expected in the regex conversion before implementation.
- How to Use
- Enter 'src/**/test*.js', enable globstar support, and add test strings like 'src/app/test.js' and 'src/lib/utils/test.js'.
- Outcome
- The regex matches all test files in any subdirectory under 'src', and test results confirm the matches are accurate.
Try with Samples
text, regexRelated Hubs
FAQ
What is a Glob pattern?
A Glob pattern is a string used for matching file paths, employing wildcards like '*' for any characters and '?' for a single character.
How does extended mode affect the conversion?
Extended mode allows brace expansion, converting patterns like '{a,b}' into regex alternations for matching multiple options.
Can I test the regex with sample strings?
Yes, use the test strings field to input file paths and see which ones match the generated regex in real-time.
Is the output regex case-sensitive?
By default, the regex is case-sensitive, but you can enable the case-insensitive option to match regardless of letter case.
What does globstar support do?
Globstar support enables the '**' wildcard to match directories recursively, allowing patterns to traverse nested folders.