<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: XLKA11</title>
    <description>The latest articles on DEV Community by XLKA11 (@xlka11).</description>
    <link>https://dev.to/xlka11</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4153237%2Fd1cdfa83-0dff-46f7-9bc7-e241689926f0.png</url>
      <title>DEV Community: XLKA11</title>
      <link>https://dev.to/xlka11</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xlka11"/>
    <language>en</language>
    <item>
      <title>How I built a VS Code extension that draws Railroad diagrams for regex and catches ReDoS</title>
      <dc:creator>XLKA11</dc:creator>
      <pubDate>Wed, 30 Sep 2026 23:18:30 +0000</pubDate>
      <link>https://dev.to/xlka11/how-i-built-a-vs-code-extension-that-draws-railroad-diagrams-for-regex-and-catches-redos-30f5</link>
      <guid>https://dev.to/xlka11/how-i-built-a-vs-code-extension-that-draws-railroad-diagrams-for-regex-and-catches-redos-30f5</guid>
      <description>&lt;p&gt;&lt;strong&gt;It started with frustration.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I write code every day. And every time I need a regex more complex than \d+, the same thing happens: I open my browser, go to a website, type the pattern, test it, copy it back to the editor. An hour later — again. And so on in a loop.&lt;br&gt;
The problem isn't that tools don't exist. The problem is they're not where I work. I don't want to switch windows to check a single line. I want everything in the editor.&lt;br&gt;
That's how Ghost Regex was born — a VS Code extension for working with regular expressions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it does&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ghost Regex is a panel inside VS Code. Opens with Ctrl+Alt+R.&lt;br&gt;
Railroad diagram. Your regex becomes a visual scheme: you see every group, every quantifier, every alternation. Colors by semantics — anchors are green, groups purple, repetitions orange. Hover for a tooltip. Export to SVG.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb1dj5rnjx79wud6cwj2t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb1dj5rnjx79wud6cwj2t.png" alt=" " width="800" height="560"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Explain + AST tree. Breaks down the expression into tokens: what each character does, how groups are nested, where the quantifier is, where the anchor is. Supports 100+ token types.&lt;/p&gt;

&lt;p&gt;ReDoS detector. Finds nested quantifiers and overlapping alternations — the stuff that can take down production on large strings. And immediately suggests a fix. Classic example: (a+)+$ becomes (a+)$.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd7zi12f4xzfatabkkbp1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd7zi12f4xzfatabkkbp1.png" alt=" " width="800" height="521"&gt;&lt;/a&gt;&lt;br&gt;
Preview on real files. Open your file, type a pattern — matches are highlighted right in the content. Not on made-up test strings, on actual data.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fugvt1ivvya0pgk43n8g9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fugvt1ivvya0pgk43n8g9.png" alt=" " width="800" height="499"&gt;&lt;/a&gt;&lt;br&gt;
Unit tests for regex. Save test strings, run them — see where it matched, where it didn't. So when you edit a regex, you don't break what already worked.&lt;br&gt;
94 built-in snippets in 8 categories: validation, dates, numbers, Web, development, extraction, Russian documents, coordinates. From Email and IPv4 to INN, SNILS, and ISBN.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F18nb5zk91wksk3c5z4gq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F18nb5zk91wksk3c5z4gq.png" alt=" " width="799" height="604"&gt;&lt;/a&gt;&lt;br&gt;
Convert. Code generation for 5 languages: Python, JavaScript, Go, Rust, Java. Plus compatibility analysis between dialects (JS, Python, Go, Rust, Java, PCRE) — which constructs don't port over.&lt;br&gt;
Sync Back. Right-click on a regex in the editor → panel → back to code. No copy-paste.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Under the hood&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Stack is simple, no exotics:&lt;br&gt;
TypeScript + Node.js&lt;br&gt;
VS Code Extension API — panel on webview&lt;br&gt;
esbuild — build&lt;br&gt;
@vscode/vsce — packaging&lt;br&gt;
Libraries:&lt;br&gt;
regex-inspector — AST parsing and ReDoS analysis&lt;br&gt;
railroad-diagrams — diagram rendering&lt;br&gt;
Architecture — 13 modules in src/: entry point, UI panel, parser, AST, code generator, ReDoS, Railroad, diagram wrapper, pattern manager, dialects, snippets, licensing, tests. Each module is isolated so changes in one don't break the others.&lt;br&gt;
How Railroad diagrams are built. The regex is first parsed into an AST. Then the AST is walked recursively: each node type — group, quantifier, alternation, anchor — becomes its own fragment of the scheme. railroad-diagrams can draw SVG, but without semantics: just black lines. I built a wrapper on top that passes CSS classes — anchors get green, groups purple, repetitions orange. Plus tooltips: hover shows what a specific node does. Rendering happens once, not on every mouse move, so even large expressions draw without lag.&lt;br&gt;
I'm not a programmer by education, I learned from scratch. This project is the second major thing I've brought to publication.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Free and Pro&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The extension uses a Free + Pro model. This isn't a "demo with cut features" — the Free version is fully functional, you can use it as long as you want.&lt;/p&gt;

&lt;p&gt;Free:&lt;/p&gt;

&lt;p&gt;Railroad diagram&lt;br&gt;
Explain + AST tree&lt;br&gt;
ReDoS detector with auto-fix&lt;br&gt;
Live test with flags (g/i/m/s/u)&lt;br&gt;
Convert for Python and JavaScript&lt;br&gt;
Dialects: JS and Python&lt;br&gt;
3 snippets (Email, URL, IPv4)&lt;br&gt;
Pro — $6/month:&lt;br&gt;
Everything from Free&lt;br&gt;
Preview on real files&lt;br&gt;
Unit tests for regex&lt;br&gt;
Sync Back&lt;br&gt;
SVG export of diagrams&lt;br&gt;
Convert for Go, Rust, Java&lt;br&gt;
Dialects: Go, Rust, Java, PCRE&lt;br&gt;
All 94 snippets&lt;br&gt;
Payment via Boosty. Subscription. Everything runs locally, no telemetry, no external &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's next&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The project is alive and growing. Near-term plans:&lt;br&gt;
Server-side license check. Right now keys are checked locally, in the client. That's fine for the first buyers, but doesn't scale. Next — Cloudflare Workers + KV: the server checks the key, the extension gets the response.&lt;br&gt;
Snippet search. 94 snippets is already a lot, soon it'll be hard to find by eye. Need a search bar with filtering by name.&lt;br&gt;
Step-by-step debugger. Not there yet — there's Railroad, AST, and Explain.&lt;br&gt;
Automated key delivery. So after purchase the key arrives by email immediately, without manual work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Feedback&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You can install the extension for free from the Marketplace. If you find a bug or want a feature — write to me, I read everything.&lt;br&gt;
Marketplace: &lt;a href="https://marketplace.visualstudio.com/items?itemName=ghost-regex.ghost-regex" rel="noopener noreferrer"&gt;https://marketplace.visualstudio.com/items?itemName=ghost-regex.ghost-regex&lt;/a&gt;&lt;br&gt;
Website: &lt;a href="https://ghost-regex-site.vercel.app" rel="noopener noreferrer"&gt;https://ghost-regex-site.vercel.app&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/XLKA11/ghost-regex" rel="noopener noreferrer"&gt;https://github.com/XLKA11/ghost-regex&lt;/a&gt;&lt;br&gt;
I'd love to hear feedback.&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>typescript</category>
      <category>regex</category>
    </item>
  </channel>
</rss>
