logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·30.10.26
← Back to news

Regex visualized as 3D marble run

Original article
regexmarblerun.com|69 points|26 comments|by seizethecheese|Oct 16, 2026

Transforming Regular Expressions into 3D Marble Courses

Regex Marble Run – your regex as a 3D marble run

Imagine if the abstract logic of a regular expression wasn't just a string of characters, but a physical architecture. Instead of staring at a wall of text visualizing the flow of data, you can now see your patterns as a tangible, three-dimensional simulation.

🛠️ How the Concept Works

The core idea is to map the state machine of a regex to a physical track. When a string is processed, it is represented by marbles rolling through the course.

The Process:

  • Define the regex pattern.
  • Convert the pattern into a 3D geometry.
  • Release marbles to simulate the matching process.

📊 Comparison: Abstract vs. Physical

FeatureStandard RegexRegex Marble Run
Representationinline code strings3D Physical Models
ExecutionLogical state transitionsGravity-driven physics
DebuggingTrial and error / Trace logsVisual path observation

📐 The Logic of the Run

In a traditional sense, a regex match can be viewed as a mathematical function where the input string SSS is accepted if there exists a path through the automaton AAA:

Match(S,A)  ⟹  ∃ path p∈A such that p consumes S\text{Match}(S, A) \implies \exists \text{ path } p \in A \text{ such that } p \text{ consumes } SMatch(S,A)⟹∃ path p∈A such that p consumes S

In the Marble Run, this is simplified: if the marble reaches the "Success" bucket, the string matches.

🗺️ Visualizing the Flow

Below is a conceptual representation of how a simple "OR" operator (|) functions in the 3D run:

💻 Example Implementation

If you were to input a pattern like the one below:

^([a-z]+)@([a-z]+)\.com$

The system would generate a series of chutes and filters. For instance, the [a-z]+ section would be a loop that keeps the marble circling until a non-lowercase character is encountered, pushing it forward to the @ gate.

Regex Marble Run Visualization

By turning the invisible logic of regex into a physical experience, the Regex Marble Run makes the complex world of pattern matching intuitive and visually stimulating.