Smart Regex Builder
Smart Regex Builder is an AI-powered Visual Studio Code extension that helps developers create, understand, and test regular expressions without leaving VS Code.
Repository: https://github.com/TigerDev-Studio/Smart-Regex-Builder
Marketplace publisher: https://marketplace.visualstudio.com/publishers/TigerDev1991
Instead of manually writing complex regex patterns, you can type simple input like:
Email
Phone Number
Date
URL
Password
Indian Mobile Number
The extension uses the VS Code Language Model API to generate a regex pattern with explanation, examples, and test cases.
Features
- Generate regex from plain English
- Explain existing regex patterns
- Generate valid and invalid examples
- Create JavaScript test code
- Validate selected text against regex
- Convert regex for JavaScript, Python, Java, PHP, and more
- Save commonly used regex patterns
- Modern VS Code webview interface with Generate, Explain, Test, Convert, and Saved tabs
- Keyboard shortcuts for opening the builder and generating regex
- Status bar icon menu for fast access to every regex action
- Works inside VS Code using the Language Model API
Example
Input:
Email
Output:
^[\w.-]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,}$
Explanation:
This regex validates a basic email format with a username, domain name, and domain extension.
Valid examples:
test@gmail.com
hello@company.in
user.name@domain.com
Invalid examples:
abc@
test.com
user@domain
JavaScript test:
const regex = /^[\w.-]+@[a-zA-Z\d.-]+\.[a-zA-Z]{2,}$/;
console.log(regex.test("test@gmail.com")); // true
console.log(regex.test("abc@")); // false
How It Works
- Open the Smart Regex Builder command from VS Code, use the shortcut, or click the status bar icon.
- Type what kind of regex you need.
- The extension sends your request to the VS Code Language Model API.
- AI generates regex, explanation, examples, and test code.
- Copy or insert the regex into your file.
Requirements
This extension uses the VS Code Language Model API.
To use AI features, you need a compatible language model provider available in VS Code, such as GitHub Copilot.
Extension Commands
| Command |
Description |
Smart Regex: Open Builder |
Open the modern regex workspace |
Smart Regex: Generate Regex |
Generate regex from plain English |
Smart Regex: Explain Regex |
Explain selected regex |
Smart Regex: Test Regex |
Test regex with sample text |
Smart Regex: Convert Regex |
Convert regex for another language |
Smart Regex: Saved Patterns |
Browse saved regex patterns |
Shortcuts and Status Bar
| Action |
Windows/Linux |
macOS |
| Open Builder |
Ctrl+Alt+R |
Cmd+Alt+R |
| Generate Regex |
Ctrl+Alt+G |
Cmd+Alt+G |
The $(regex) Smart Regex status bar icon opens a quick menu for Generate, Explain, Test, Convert, and Saved Patterns.
Development
npm install
npm run compile
Press F5 in VS Code to launch the extension development host.
Use Cases
- Form validation
- Email and phone validation
- Date format matching
- URL validation
- Password rules
- Log parsing
- Data extraction
- Search and replace patterns
Why Smart Regex Builder?
Regex is powerful, but difficult to write and understand. Smart Regex Builder makes regex easier by combining AI generation, clear explanations, and quick testing directly inside VS Code.
License
MIT