Regex visualized as 3D marble run
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
| Feature | Standard Regex | Regex Marble Run |
|---|---|---|
| Representation | inline code strings | 3D Physical Models |
| Execution | Logical state transitions | Gravity-driven physics |
| Debugging | Trial and error / Trace logs | Visual 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 is accepted if there exists a path through the automaton :
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.

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.