# Glob to Regex

Convert file matching patterns (Glob) to regular expressions

> Canonical page: https://elysiatools.com/en/tools/glob-to-regex

- **Category:** Development

- **Keywords:** glob, regex, pattern, file matching, conversion, Glob转正则

## Overview

Convert Glob patterns like `src/**/*.ts` to standard regular expressions. Useful for understanding Glob patterns and creating custom file matching logic.

## Inputs

- **Glob Pattern** (text): e.g., src/**/*.ts
- **Extended Mode** (checkbox): Support brace expansion like {a,b,c}
- **Globstar Support** (checkbox): Support ** for recursive directory matching
- **Case Insensitive** (checkbox): Match regardless of case
- **Test Strings (Optional)** (textarea): One string per line. Results will show which strings match.

## 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

- Integrating file matching in build tools or automation scripts that rely on regular expressions.
- Creating custom ignore patterns for version control systems or file watchers that use regex.
- Developing file search functionality in desktop or web applications requiring pattern-based filtering.

## Frequently asked questions

### 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.

## Related tools

- [AI Regex Explainer](https://elysiatools.com/en/tools/ai-regex-explainer): Use AI to break down regular expressions into readable explanations
- [Regex to String Generator](https://elysiatools.com/en/tools/regex-to-string-generator): Generate random strings that match a given regular expression pattern
- [Named Group Tester](https://elysiatools.com/en/tools/named-group-tester): Parse and display named capture groups from regex patterns
- [Java Regex Tester](https://elysiatools.com/en/tools/java-regex-tester): Test java.util.regex patterns online: (?…) named groups, possessive quantifiers and atomic groups, Pattern flags, ASCII vs UNICODE\_CHARACTER\_CLASS \\d semantics, and ready-to-paste Java code.
- [PCRE2 Regex Tester](https://elysiatools.com/en/tools/pcre-regex-tester): Test PCRE2 patterns online: every named-group syntax ((?P), (?), (\\u0027n\\u0027)), possessive quantifiers, atomic groups, \\A \\z \\h shorthands, plus pcre2grep and C API snippets.
- [Multi-Pattern Matcher](https://elysiatools.com/en/tools/multi-pattern-matcher): Match multiple regex patterns against text in one operation
- [Bulk Email Extractor](https://elysiatools.com/en/tools/bulk-email-extractor): Extract all email addresses from input text, articles, web source code, or mixed content. Supports deduplication and export to JSON.
- [C# Regex Tester (.NET)](https://elysiatools.com/en/tools/csharp-regex-tester): Test .NET/C# regular expressions online with named groups ((?…)), IgnoreCase/Multiline/Singleline options, match highlighting, capture-group tables, a ready-to-paste C# snippet and an IgnorePatternWhitespace preview.

## Samples

- [Regex Replace Samples](https://elysiatools.com/en/samples/regex-replace): Collection of common and useful regex replacement patterns for text transformation and data cleaning
- [Common Regex Patterns](https://elysiatools.com/en/samples/regex-samples): Commonly used regular expression patterns for validation and matching
- [Regex Pattern Alternatives](https://elysiatools.com/en/samples/regex-alternatives): Multiple ways to write the same regex pattern with different trade-offs in readability, performance, and accuracy
- [Regex Named Capture Groups](https://elysiatools.com/en/samples/regex-named-groups): Collection of regex patterns using named capture groups for extracting structured data from text. Named groups make patterns more readable and maintainable by assigning meaningful names to captured portions.

## Related content

- [Regex Testing, Visualization, and Safety Workflow](https://elysiatools.com/en/hubs/regex-utility): Build reliable regular expressions by learning syntax, testing matches, visualizing structure, previewing replacements, benchmarking alternatives, and scanning for ReDoS risk.
