Skip to content
Back to skills

Regex Builder Parser

ASecurity

Construct ReDoS-safe regular expressions and string parser logic for complex input string extraction.

  • 2 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 27, 2026
developmentjavascriptpythongojavabashnodeexpresstesting

Security analysis

A92/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned September 27, 2026

npx -y skills add RMAzrim/opencode-artes --skill regex-builder-parser --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Regex Builder Parser?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Regex Builder Parser
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/rmazrim-regex-builder-parser/badge)](https://www.skillsdirectory.com/skills/rmazrim-regex-builder-parser)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: Regex Builder & Parser
description: Construct ReDoS-safe regular expressions and string parser logic for complex input string extraction.
metadata:
  source: skills/regex-builder-parser/regex-builder-parser.md
---

# Regex Builder & Parser

## Prerequisites & Dependencies
- Node.js 18+ or Python 3.10+ with regex engine knowledge
- `npm i redoS` (for safety scoring) or Python's `re` module + `rstr` for generation
- Comfortable with character classes, quantifiers, grouping, and anchors

## Execution Steps
1. Clearly define the input format and extraction goal: what substrings, delimiters, or patterns must be captured
2. Sketch the regex on paper first: anchors (`^`, `$`), delimiters, optional groups, alternation (`|`)
3. Build the regex incrementally, testing each component against sample inputs before compositing
4. Use atomic groups `(?>...)` or possessive quantifiers `++`/`*`+` (if supported) to prevent backtracking exploits
5. Score the regex for ReDoS risk: `npm i redoS` → `checkRegex(regex)` should report low catastrophic backtracking risk
6. Favor simpler alternatives: string methods (`split`, `match`), `String.prototype.replace`, or parser combinators if the pattern exceeds ~20 characters or has nested quantifiers
7. Document the final regex with inline comments `/** @type {RegExp} */` and a brief explanation of each section

```javascript
// Safe regex: extract filename without extension from a path
// Breakdown: ^ anchors start, [^/]+ matches one or more non-slash chars, \. matches literal dot, $ anchors end
// Atomic group prevents backtracking on malicious inputs
const safeFilenameRegex = /^(?>[^/]+)\.([^.]+)$/;

// Test cases
const tests = [
  { input: '/path/to/document.pdf', expected: 'document', desc: 'pdf extension' },
  { input: 'archive.tar.gz', expected: 'archive', desc: 'double extension (should match first)' },
  { input: 'noext', expected: 'noext', desc: 'no dot, return basename' },
];

tests.forEach(({ input, expected, desc }) => {
  const match = input.match(safeFilenameRegex);
  const ok = match && match[1] === expected;
  console.log(`${desc}: "${input}" → ${match ? match[1] : 'null'} ${ok ? '✅' : '❌'}`);
});
```

```bash
# ReDoS safety check (Node)
const { checkRegex } = require('redoS');
const regex = /^(?>[^/]+)\.([^.]+)$/;
const result = checkRegex(regex, 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.');
console.log(result); // { safe: true, maxIterations: ... } or warns about backtracking
```
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.