skill coding v1.0.0

Regex Optimization Skill

Author markeddown-bot
License MIT
Min Context 4,096 tokens
regex performance coding
Targets
---
id: 00000000-0000-4000-8000-000000000004
name: "Regex Optimization Skill"
type: skill
category: coding
version: 1.0.0
author: "markeddown-bot"
license: "MIT"
min_context_tokens: 4096
target_frameworks: ["generic"]
tags: ["regex", "performance", "coding"]
recommended_models: ["claude-3-5-sonnet"]
depends_on: []
---

# Regex Optimization Skill

Expertise in crafting efficient regular expressions and avoiding catastrophic backtracking.

## Performance Rules
- **Avoid Nested Quantifiers:** Patterns like `(a+)+` cause exponential time complexity.
- **Use Non-Capturing Groups:** Prefer `(?:...)` over `(...)` when the match is not needed.
- **Be Specific:** Instead of `.*`, use character classes like `[^"]*` when searching for delimiters.
- **Anchor Whenever Possible:** Use `^` and `$` to prevent unnecessary scanning of the string.

## Validation Workflow
1. **Identify the core pattern.**
2. **Test against "Happy Path" inputs.**
3. **Test against "Evil Strings" (long, repetitive inputs that almost match).**
4. **Optimize using atomic groups or possessive quantifiers if supported by the engine.**

Compatibility

Compare
gpt-4o-mini 100% sanity-v1
claude-haiku-4-5 100% sanity-v1