Your regex pattern library, organized and ready to go (for Sublime Text 4)
Never dig through old files or re-Google regex patterns again. Save them in portfolios, load them instantly, and get back to coding.
๐น Video Note: If you're watching older demonstration videos, please note that keyboard shortcuts were updated to comply with Package Control guidelines. Videos show previous shortcuts, but functionality remains identical with the new bindings listed below.
โก Now available! Install RegexLab directly from Package Control:
- Open Command Palette (
Ctrl+Shift+P/Cmd+Shift+P) - Run
Package Control: Install Package - Search for RegexLab
- Install and enjoy! ๐
Package Control automatically handles updates when new versions are released.
Want to track the repo right now? Add it as a custom source:
- Open the Command Palette โ
Package Control: Add Repository - Paste
https://github.com/KaminoU/RegexLab - Command Palette โ
Package Control: Install Package - Search for RegexLab โ Install
Package Control remembers the custom repository, so future updates come through the same workflow. Once RegexLab lands in the default channel you can remove the custom entry if you prefer.
-
Clone or download this repository:
git clone https://github.com/KaminoU/RegexLab.git
-
Locate your Sublime Text
Packagesdirectory:- Windows:
%APPDATA%\Sublime Text\Packages\ - macOS:
~/Library/Application Support/Sublime Text/Packages/ - Linux:
~/.config/sublime-text/Packages/
๐ก Tip:
Preferences > Browse Packages...opens the right folder. - Windows:
-
Copy the
RegexLabfolder intoPackages -
Restart Sublime Text โ the built-in portfolios load automatically on startup. ๐
Press Ctrl+K, Ctrl+R (or Cmd+K, Cmd+R on macOS) to open the pattern selector:
- Browse patterns from all active portfolios
- Select a pattern
- The regex is injected into the Find panel
- Adjust scope and search!
- Select text in your file (e.g.,
API_KEY) - Press
Ctrl+K, Ctrl+U(orCmd+K, Cmd+Uon macOS) - Choose an action:
- โจ Create New Pattern / Save to portfolio with a name
- ๐ Use as Find Pattern / Inject directly into Find panel
- ๐ Use as Replace Pattern / Inject into Replace panel
- ๐ Use as Find in Files / Inject into Find in Files panel
Press Ctrl+K, Ctrl+P (or Cmd+K, Cmd+P on macOS) to open the Portfolio Manager:
- View all loaded and disabled portfolios
- Enable/disable portfolios with one click
- Create new portfolios via wizard
- Reload portfolios without restarting Sublime Text
RegexLab provides convenient keyboard shortcuts for lightning-fast access:
| Shortcut | Command | What it does |
|---|---|---|
Ctrl+K, Ctrl+R (Cmd+K, Cmd+R) |
Load Pattern | Open pattern selector and inject regex into Find panel |
Ctrl+K, Ctrl+P (Cmd+K, Cmd+P) |
Portfolio Manager | Visual hub for managing all portfolios |
Ctrl+K, Ctrl+U (Cmd+K, Cmd+U) |
Use Selection | Quick actions on selected text: save as pattern or inject into panels |
๐ก Tip: Customize these shortcuts in Preferences > Package Settings > RegexLab > Key Bindings
RegexLab auto-discovers portfolios from these locations:
Built-in (always loaded, integrity-protected):
RegexLab/data/portfolios/*.json
Custom active (auto-loaded on startup):
User/RegexLab/portfolios/*.json
Disabled (ignored, not loaded):
User/RegexLab/disabled_portfolios/*.json
Enable/disable portfolios:
- Use Portfolio Manager (
Ctrl+K, Ctrl+P) โ "Enable/Disable Portfolio" - Or drag
.jsonfiles betweenportfolios/anddisabled_portfolios/
Create new portfolio:
- Command Palette โ "RegexLab: New Portfolio"
- Follow the 5-step wizard (name, description, author, tags, confirmation)
- Portfolio automatically saved to
User/RegexLab/portfolios/
๐ Learn more: Portfolio Management Guide
Dynamic patterns use variables that are resolved when you load the pattern. Think of them as reusable templates.
Example pattern:
\[{{LEVEL}}\] {{DATE}} - {{MESSAGE}}When you load this pattern, RegexLab prompts you for each variable value:
LEVELโ Enter:INFODATEโ Pre-filled with today's date:2025-10-26MESSAGEโ Enter:User logged in
Final resolved regex:
\[INFO\] 2025-10-26 - User logged inThe following variables are auto-filled with the current date/time by default. You can adjust their formats in RegexLab.sublime-settings:
{{DATE}}โ Usesvariables.date_format(default:%Y-%m-%d). Default value is"NOW"viavariables_assertion.DATE.default.{{TIME}}โ Usesvariables.time_format(default:%H:%M:%S). Default value is"NOW"viavariables_assertion.TIME.default.
Note: These built-in defaults are provided out of the box and can be overridden in RegexLab.sublime-settings. For other variables (e.g., {{USERNAME}}, {{LEVEL}}, {{EMAIL}}, {{IP}}, {{PORT}}, {{UUID}}), prompting and validation are fully controlled by your variables_assertion configuration.
You can use any variable name you want:
{{TASK}},{{PRIORITY}},{{AUTHOR}},{{SERVER}}, etc.- RegexLab prompts you for the value when loading the pattern
- No pre-configuration needed ; just use them!
Want to validate user input for variables? Define constraints in settings!
Example: Force {{DATE}} to be in YYYY-MM-DD format:
// Settings: Preferences > Package Settings > RegexLab > Settings
{
"variables_assertion": {
"DATE": {
"regex": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
"default": "NOW",
"hint": "YYYY-MM-DD format",
"example": "2025-10-26"
},
"LEVEL": {
"regex": "DEBUG|INFO|WARN|ERROR",
"default": "INFO",
"hint": "Log severity level",
"example": "DEBUG, INFO, WARN, ERROR"
}
}
}What this does:
regex: Validates input against this patterndefault: Pre-fills the input (use"NOW"for auto date/time)hint: Shows helpful description in promptexample: Shows example values
Prompt example with validation:
Enter value for {{DATE}} (hint: YYYY-MM-DD format, e.g. 2025-10-26):
Customize how {{DATE}}, {{TIME}}, and {{DATETIME}} are formatted:
{
"variables": {
"date_format": "%Y-%m-%d", // Default: 2025-10-26
"time_format": "%H:%M:%S", // Default: 15:30:45
"datetime_format": "%Y-%m-%d %H:%M:%S" // Default: 2025-10-26 15:30:45
}
}๐ Learn more: See RegexLab.sublime-settings for all available options
Method 1: New Portfolio Wizard (recommended)
- Command Palette โ "RegexLab: New Portfolio"
- Follow the wizard steps
- Add patterns via Portfolio Manager
Method 2: JSON file (advanced)
Create User/RegexLab/portfolios/my-portfolio.json:
{
"name": "My Custom Portfolio",
"description": "Project-specific patterns",
"version": "1.0.0",
"author": "Your Name",
"readonly": false,
"patterns": [
{
"name": "API Endpoint",
"regex": "/api/v\\d+/[\\w/-]+",
"type": "static",
"description": "Match REST API endpoints"
},
{
"name": "Email Finder",
"regex": "[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}",
"type": "static",
"description": "Find emails across files",
"default_panel": "find_in_files"
}
]
}๐ก Smart Panel Targeting: Patterns can auto-select the best panel via default_panel:
"find_in_files"โ Multi-file search (emails, URLs, IPs)"replace"โ Cleanup patterns (whitespace, duplicates)- Omit for validation patterns (user decides context)
default_panel automatically! Manual JSON editing is error-prone.
Restart Sublime Text or reload portfolios (Ctrl+K, Ctrl+P โ "Reload Portfolios").
๐ Learn more: Portfolio Schema Documentation
- Sublime Text 4 (Build 4050+)
That's it! If Sublime Text 4 runs on your system, RegexLab will work. โจ
RegexLab has comprehensive test coverage and production-grade quality:
Core tests (pytest):
- โ 533 tests passing on Python 3.8 and 3.13
- โ 98% coverage (1214 statements, 29 miss)
- โ
Per-module breakdown:
models.py: 100% (core data structures)pattern_engine.py: 100% (regex engine)logger.py: 100% (logging infrastructure)portfolio_service.py: 99% (portfolio operations)panel_injection.py: 98% (UI integration)settings_manager.py: 97% (settings management)integrity_manager.py: 97% (security)portfolio_manager.py: 94% (portfolio lifecycle)helpers.py: 92% (utilities)
UI tests (UnitTesting):
- โ 6 tests passing (Sublime Text integration)
- โ Validates commands, portfolio loading, pattern injection
Total: 539 tests across all layers ๐ฏ
Run tests yourself:
tox # Full test suite (all Python versions)
pytest tests/ -v # Quick test runRegexLab is blazing fast with enterprise-grade optimizations:
- โก 333x speedup on
Pattern.variables(3.33ยตs vs 1.11ms)- Cached property optimization โ O(1) after first access
- โก 13x speedup on
Pattern.resolve()(76.9ยตs vs 1ms)- Pre-compiled regex patterns โ zero runtime compilation
- โ CCode audit score: 9.8/10 (production-ready)
- โ Zero memory leaks detected
- โ <1% code duplication
- โ 100% type hints (mypy strict mode)
- โ Cross-platform validated (Windows, Linux, macOS)
- ๐ก๏ธ OOM protection for clipboard operations (10MB limit)
- ๐ก๏ธ Defensive programming for edge cases
- ๐ก๏ธ Proper resource cleanup (no file handle leaks)
Got a useful portfolio to share? The community would love to see it!
How to share:
- Create a Gist: Upload your portfolio JSON to GitHub Gist
- Share it: Post the link in GitHub Discussions (coming soon!)
- Tag it: Add relevant tags (Python, Web, DevOps, Data Science, etc.)
What makes a good community portfolio?
- ๐ฏ Focused on a specific domain or use case
- ๐ Well-documented patterns with clear descriptions
- โ Tested and verified regex patterns
- ๐ก Solves real-world problems
Coming soon! Be the first to share yours! ๐
How to use community portfolios:
- Download the JSON file from the gist
- Save it to
User/RegexLab/portfolios/ - Restart Sublime Text or reload portfolios (
Ctrl+K, Ctrl+Pโ "Reload Portfolios")
Popular ideas for portfolios:
- Python/Django patterns (imports, decorators, ORM queries)
- Web scraping toolkit (HTML tags, data extraction)
- Data science patterns (CSV, JSON, scientific notation)
- DevOps/Infrastructure (config files, YAML, Docker)
- Security/Forensics (IP addresses, credentials, hashes)
Best portfolios may be included in future builtin releases! ๐
Contributions are super welcome! ๐
Before you start, please read our Contributing Guide for:
- Code style guidelines
- Testing requirements
- Pull request process
- Development setup
# Clone the repository
git clone https://github.com/KaminoU/RegexLab.git
cd RegexLab
# Install tox (if not already installed)
pip install tox
# Run full test suite (Python 3.8 + 3.13, linting, type checking)
tox
# Run specific tests
tox -e py38-core # Tests on Python 3.8
tox -e py313-core # Tests on Python 3.13
tox -e lint # Linting only (ruff)
tox -e typecheck # Type checking only (mypy)
# Quick development workflow
pytest tests/ -v # Run all tests
ruff check src/ tests/ --diff # Lint (matches CI guardrail)
mypy src/ # Type check
# WSL2/headless testing (no Sublime Text UI)
bash scripts/test-wsl2.sh # Linux/WSL2
pwsh scripts/test-wsl2.ps1 # PowerShellCoverage targets for new code:
- Core modules (
models.py,pattern_engine.py): 95%+ - Utilities (
helpers.py,logger.py): 65%+ - Commands (UI): 50%+
๐ Full guide: CONTRIBUTING.md
Copyright ยฉ 2025 ๅฎะamiๅฎ (Michel TRUONG)
Licensed under the MIT License. See LICENSE for details.
See CHANGELOG.md for version history and release notes.
- Author: Michel TRUONG (KaminoU)
- Contributors: Thank you to everyone who helps improve RegexLab! โค๏ธ
Made with โค๏ธ for the Sublime Text community.
o( ^ ^ )o Cheers!!! o( ^ ^ )o