OpenClaw Regex Engine v2.0
Master regular expressions -- 5 tools to test, explain, build, browse, and replace patterns instantly.
Quick Reference
| Situation | Action | Tool |
|---|
| Have a regex, need to test it | Run against text, get all matches + groups | INLINECODE0 |
| Found a scary regex in legacy code |
Get plain-English breakdown of every token |
regex_explain |
| Know WHAT to match but not HOW | Describe in English, get production regex |
regex_build |
| Need a standard pattern (email, URL, IP) | Browse 50+ battle-tested patterns |
regex_library |
| Need to transform text with regex | Find-replace with backreferences ($1, $2) |
regex_replace |
| Complex pattern with capture groups | Test + Explain combo for full understanding |
regex_test +
regex_explain |
What's New in v2.0
- - :brain: PatternForge Builder -- Describe what you want in plain English. Get a production-ready regex with positive/negative test cases, flags, and explanation included.
- :book: RegexLens Explainer -- Break any regex into human-readable components token-by-token. Even nested lookaheads, possessive quantifiers, and Unicode categories.
- :filecabinet: BattleTest Library -- 50+ curated patterns for email, URL, phone (international), IPv4/IPv6, UUID, JWT, credit card, date formats, file paths, and more. Every pattern includes test cases.
- :arrowscounterclockwise: SmartReplace Engine -- Full backreference support including named groups, global/first-match modes, and before/after diff preview.
MCP Quick Start
CODEBLOCK0
Add to Claude Desktop, Cursor, Windsurf, VS Code, or any MCP-compatible client. No API key needed for Free tier. Works immediately.
Detection Triggers
This skill activates when you say:
- - "test this regex" / "does this pattern match" / "run this regex against"
- "explain this regex" / "what does this regex do" / "break down this pattern"
- "build a regex for" / "create a pattern that matches" / "regex for emails"
- "regex for URL" / "phone number regex" / "UUID pattern" / "IP address regex"
- "regex replace" / "find and replace with regex" / "search and replace with capture groups"
- "regular expression" / "pattern matching" / "capture groups" / "backreference"
Tools (5)
regex_test -- Match & Capture (PatternMatch Protocol)
Test a regex pattern against input text. Returns every match with full capture group detail, named groups, and exact index positions.
| Parameter | Type | Default | Description |
|---|
| INLINECODE8 | string | required | Regex pattern to test |
| INLINECODE9 |
string | required | Input text to match against |
|
flags | string | "g" | Flags:
g global,
i case-insensitive,
m multiline,
s dotall,
u unicode,
v unicodeSets |
Output: INLINECODE17
WRONG vs RIGHT
WRONG -- Manually scanning text to check if a pattern works:
CODEBLOCK1
RIGHT -- Use regex_test:
User: Does this regex match my test string?
Agent: calls regex_test → "3 matches found. Match 1 at index 15: 'user@example.com', group 1: 'user', group 2: 'example.com'"
regex_explain -- Human-Readable Breakdown (RegexLens)
Break any regex into plain English, token by token. Each component gets a description, what it matches, and example matches.
| Parameter | Type | Default | Description |
|---|
| INLINECODE20 | string | required | Regex pattern to explain |
| INLINECODE21 |
string | "" | Active flags to include in explanation |
Handles: Character classes, quantifiers, anchors, groups (capturing, non-capturing, named), lookahead/lookbehind (positive and negative), backreferences, Unicode categories, and alternation.
Output: Array of { token, type, description, matches_example } plus overall summary.
WRONG vs RIGHT
WRONG -- Staring at ^(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%])[A-Za-z0-9!@#$%]{8,}$ and guessing:
CODEBLOCK3
RIGHT -- Use regex_explain:
User: What does this regex do?
Agent: calls regex_explain → "Password validator: requires at least 1 uppercase letter (lookahead 1), 1 digit (lookahead 2), 1 special char from !@#$% (lookahead 3), minimum 8 characters total from allowed set"
regex_build -- Natural Language to Regex (PatternForge)
Describe what you want to match in plain English. Get a production-ready regex with recommended flags, explanation, and test cases (both positive and negative).
| Parameter | Type | Default | Description |
|---|
| INLINECODE26 | string | required | Plain English description of what to match |
| INLINECODE27 |
object | {} |
strict: boolean for anchored patterns,
examples: string[] for guidance |
Output: INLINECODE30
Example: Input "match email addresses" produces a complete RFC-5322-lite pattern with 5 positive and 5 negative test cases.
regex_library -- Pattern Collection (BattleTest Library)
Browse 50+ curated, production-tested regex patterns organized by category. Every pattern includes the regex string, description, recommended flags, and positive/negative test cases.
| Parameter | Type | Default | Description |
|---|
| INLINECODE32 | string | "" | Filter by category: email, url, ip, phone, date, uuid, jwt, credit_card, password, html, file_path, INLINECODE44 |
| INLINECODE45 |
string | "" | Free-text search across pattern names and descriptions |
Categories: email, URL, IPv4, IPv6, phone (US, UK, JP, international), date (ISO, US, EU), UUID (v1-v5), JWT, credit card (Visa, MC, Amex), password strength, HTML tags, file paths (Unix, Windows), CSS selectors, color codes, semantic versioning.
regex_replace -- Find & Replace (SmartReplace Engine)
Perform regex-based find-and-replace with full capture group reference support ($1, $2, named groups), global and first-match modes.
| Parameter | Type | Default | Description |
|---|
| INLINECODE47 | string | required | Regex pattern to find |
| INLINECODE48 |
string | required | Replacement string with
$1,
$2,
$<name> references |
|
text | string | required | Input text to transform |
|
flags | string | "g" | Regex flags |
Output: INLINECODE54
Supports: $1-$9 numbered backreferences, $<name> named backreferences, $& full match, ` $ ` pre-match, $' post-match.
## What NOT to Do
| Don't | Why | Do Instead |
|-------|-----|------------|
| Use catastrophic backtracking patterns like (a+)+$ | Will timeout on edge workers (~50ms limit) | Rewrite with atomic groups or possessive quantifiers |
| Expect PCRE-only features (conditional patterns, recursion) | Uses JavaScript ES2024 regex engine | Stick to JS-compatible syntax |
| Send input text over 100KB | Memory limits on edge workers | Split large texts into chunks |
| Rely on patterns for security validation alone | Regex is for format checking, not sanitization | Combine with server-side validation |
| Use regexbuild for complex parsers | NL-to-regex handles single patterns, not grammars | Build complex patterns manually with regexexplain` to verify |
Security & Privacy
| What | Status |
|---|
| Reads your input text and patterns | Yes -- for processing only |
| Stores your data |
No -- zero persistence, stateless edge processing |
| Sends data to third parties |
No -- processed entirely on Cloudflare Workers |
| Logs request content |
No -- only anonymous usage counters |
| Executes patterns server-side | Yes -- sandboxed with 50ms timeout to prevent ReDoS |
| Requires authentication | Free tier: no. Pro: API key header only |
Pricing
| Tier | Calls/Day | Price | What You Get |
|---|
| Free | 20 | $0 | All 5 regex tools, no signup |
| Pro |
1,000 | $9/mo | All 9 OpenClaw servers (49 tools), priority routing |
| x402 | Pay-per-call | $0.05 USDC | No account needed, crypto-native |
Get Pro Key: https://buy.stripe.com/4gw5na5U19SP9TW288
The OpenClaw Intelligence Stack
| Server | Tools | Best For |
|---|
| JSON Toolkit | 6 | Format, validate, diff, query, transform JSON |
| Regex Engine |
5 | Test, extract, replace, explain regex patterns |
|
Color Palette | 5 | Generate, convert, harmonize, accessibility-check colors |
|
Timestamp Converter | 5 | Parse, format, diff, timezone-convert timestamps |
|
Prompt Enhancer | 6 | Optimize, rewrite, score, A/B test AI prompts |
|
Market Intelligence | 6 | AI market trends, GitHub stats, competitor analysis |
|
Fortune & Tarot | 3 | Daily fortune, tarot readings, I Ching |
|
Content Publisher | 8 | MoltBook posts, social content, newsletter |
|
AgentForge Compare | 5 | Compare AI tools, frameworks, MCP servers |
All 9 servers share one Pro key. $9/mo = 49 tools.
OpenClaw正则表达式引擎 v2.0
精通正则表达式——5款工具,即刻测试、解释、构建、浏览和替换模式。
快速参考
| 场景 | 操作 | 工具 |
|---|
| 有正则表达式,需要测试 | 对文本运行,获取所有匹配项 + 分组 | regextest |
| 在遗留代码中发现可怕的正则表达式 |
获取每个标记的通俗易懂的分解说明 | regexexplain |
| 知道要匹配什么但不知道如何匹配 | 用英语描述,获取生产级正则表达式 | regex_build |
| 需要标准模式(邮箱、URL、IP) | 浏览50+经过实战检验的模式 | regex_library |
| 需要用正则表达式转换文本 | 使用反向引用($1, $2)进行查找替换 | regex_replace |
| 带有捕获组的复杂模式 | 测试+解释组合,全面理解 | regex
test + regexexplain |
v2.0 新特性
- - :brain: PatternForge 构建器 —— 用通俗英语描述你的需求。获取包含正/负测试用例、标志和解释的生产级正则表达式。
- :book: RegexLens 解释器 —— 将任何正则表达式逐标记分解为人类可读的组件。甚至包括嵌套前瞻、占有量词和Unicode类别。
- :filecabinet: BattleTest 库 —— 50+精心策划的模式,涵盖邮箱、URL、电话(国际)、IPv4/IPv6、UUID、JWT、信用卡、日期格式、文件路径等。每个模式都包含测试用例。
- :arrowscounterclockwise: SmartReplace 引擎 —— 完全支持反向引用,包括命名组、全局/首次匹配模式以及前后差异预览。
MCP 快速入门
json
{
openclaw-regex: {
type: streamable-http,
url: https://regex-engine-mcp.yagami8095.workers.dev/mcp
}
}
添加到Claude Desktop、Cursor、Windsurf、VS Code或任何兼容MCP的客户端。免费层无需API密钥。即刻生效。
触发检测
当你说以下内容时,此技能将被激活:
- - 测试这个正则表达式 / 这个模式是否匹配 / 对这个文本运行这个正则表达式
- 解释这个正则表达式 / 这个正则表达式做什么 / 分解这个模式
- 构建一个正则表达式用于 / 创建一个匹配...的模式 / 邮箱的正则表达式
- URL的正则表达式 / 电话号码正则表达式 / UUID模式 / IP地址正则表达式
- 正则替换 / 用正则查找并替换 / 用捕获组搜索并替换
- 正则表达式 / 模式匹配 / 捕获组 / 反向引用
工具(5个)
regex_test —— 匹配与捕获(PatternMatch协议)
针对输入文本测试正则表达式模式。返回每个匹配项及其完整的捕获组详情、命名组和精确索引位置。
| 参数 | 类型 | 默认值 | 描述 |
|---|
| pattern | 字符串 | 必填 | 要测试的正则表达式模式 |
| text |
字符串 | 必填 | 要匹配的输入文本 |
| flags | 字符串 | g | 标志:g全局,i不区分大小写,m多行,s点号通配,uUnicode,vUnicodeSets |
输出:{ matchCount, matches: [{ index, match, groups: [], namedGroups: {} }], executionTimeMs }
错误 vs 正确
错误 —— 手动扫描文本来检查模式是否有效:
用户:这个正则表达式能匹配我的测试字符串吗?
代理:目视阅读正则表达式,猜测是的应该能匹配 —— 遗漏了嵌套组的边界情况
正确 —— 使用 regex_test:
用户:这个正则表达式能匹配我的测试字符串吗?
代理:调用 regex_test → 找到3个匹配项。匹配项1位于索引15:user@example.com,组1:user,组2:example.com
regex_explain —— 人类可读的分解说明(RegexLens)
将任何正则表达式逐标记分解为通俗英语。每个组件都包含描述、匹配内容以及匹配示例。
| 参数 | 类型 | 默认值 | 描述 |
|---|
| pattern | 字符串 | 必填 | 要解释的正则表达式模式 |
| flags |
字符串 | | 要包含在解释中的活动标志 |
处理范围:字符类、量词、锚点、分组(捕获型、非捕获型、命名型)、前瞻/后顾(正向和负向)、反向引用、Unicode类别和交替。
输出:{ token, type, description, matches_example } 数组加上总体摘要。
错误 vs 正确
错误 —— 盯着 ^(?=.[A-Z])(?=.[0-9])(?=.*[!@#$%])[A-Za-z0-9!@#$%]{8,}$ 猜测:
用户:这个正则表达式做什么?
代理:猜测 它可能匹配密码? —— 没有关于前瞻或最小长度的细节
正确 —— 使用 regex_explain:
用户:这个正则表达式做什么?
代理:调用 regex_explain → 密码验证器:要求至少1个大写字母(前瞻1),1个数字(前瞻2),1个来自!@#$%的特殊字符(前瞻3),允许字符集至少8个字符
regex_build —— 自然语言转正则表达式(PatternForge)
用通俗英语描述你想要匹配的内容。获取包含推荐标志、解释和测试用例(正例和反例)的生产级正则表达式。
| 参数 | 类型 | 默认值 | 描述 |
|---|
| description | 字符串 | 必填 | 要匹配内容的通俗英语描述 |
| options |
对象 | {} | strict: boolean 用于锚定模式,examples: string[] 用于指导 |
输出:{ pattern, flags, explanation, testCases: { shouldMatch: [], shouldNotMatch: [] } }
示例:输入匹配邮箱地址生成一个完整的RFC-5322精简模式,附带5个正例和5个反例测试用例。
regex_library —— 模式集合(BattleTest库)
浏览50+按类别组织的、经过生产测试的正则表达式模式。每个模式都包含正则表达式字符串、描述、推荐标志以及正/反测试用例。
| 参数 | 类型 | 默认值 | 描述 |
|---|
| category | 字符串 | | 按类别筛选:email、url、ip、phone、date、uuid、jwt、creditcard、password、html、filepath、css |
| search |
字符串 | | 跨模式名称和描述的自由文本搜索 |
类别:邮箱、URL、IPv4、IPv6、电话(美国、英国、日本、国际)、日期(ISO、美国、欧盟)、UUID(v1-v5)、JWT、信用卡(Visa、MC、Amex)、密码强度、HTML标签、文件路径(Unix、Windows)、CSS选择器、颜色代码、语义化版本。
regex_replace —— 查找与替换(SmartReplace引擎)
执行基于正则表达式的查找替换,完全支持捕获组引用($1、$2、命名组),支持全局和首次匹配模式。
| 参数 | 类型 | 默认值 | 描述 |
|---|
| pattern | 字符串 | 必填 | 要查找的正则表达式模式 |
| replacement |
字符串 | 必填 | 包含 $1、$2、$
引用的替换字符串 |
| text | 字符串 | 必填 | 要转换的输入文本 |
| flags | 字符串 | g | 正则表达式标志 |
输出:{ result, replacementCount, diff: { before, after } }
支持:$1-$9 编号反向引用、$ 命名反向引用、$& 完整匹配、 $ 匹配前文本、$ 匹配后文本。
不要做的事
| 不要 | 原因 | 改为 |
|---|
| 使用灾难性回溯模式如 (a+)+$ | 会在边缘工作者上超时(约50ms限制) |
使用原子组