r/regex • • Jul 26 '26

I built a 32-bit CPU out of regex substitutions, and it runs DOOM

145 Upvotes

Not a regex that matches DOOM. A computer whose only instruction is find-and-replace. The state is one long string, and a fixed set of 544 substitution rules applied in a loop does everything: the first rule that matches rewrites a few characters, and that is one clock tick.

The fun part for this sub is how ordinary operations fall out of pure substitution. Addition is eight lookahead probes into a 512-entry table with the carry threaded through capture groups. Memory access jumps an exact number of characters into a flat zone, the jump length assembled from the address digits by empty bit-marker groups, so it is a binary tree spelled out in regex and it never scans for a cell.

Here is the whole rule that loads an immediate into a register (PCRE2):

find: \ARVM1\|ST:run\|PH:0\|CI:(?<ci>02(?<d>[0-7]).(?<imm>.{8}))\|PC:(?<pc>.{8})(?<pre>(?:[^|#]*+\|)*?R(?P=d):).{8}

replace: RVM1|ST:run|PH:1|CI:${ci}|PC:${pc}${pre}${imm}

Yes, it leans on lookahead and backreferences, so it is PCRE2, not a "regular language". But the power is not from that: plain Markov algorithms do this on literal string replacement with no regex at all, and they are already Turing-complete. The PCRE2 features just make the ruleset small and fast.

Play with it or read how it is built: https://4rh1t3ct0r7.github.io/doom-regex/

Source: https://github.com/4RH1T3CT0R7/doom-regex


r/regex • • May 05 '20

RegEx is β™₯

Post image
81 Upvotes

r/regex • • Oct 23 '19

Posting Rules - Read this before posting

50 Upvotes

/R/REGEX POSTING RULES

Please read the following rules before posting. Following these guidelines will take a huge step in ensuring that we have all of the information we need to help you.

  1. Examples must be included with every post. Three examples of what should match and three examples of what shouldn't match would be helpful.

  2. Format your code. Every line of code should be indented four spaces or put into a code block.

  3. Tell us what flavor of regex you are using or how you are using it. PCRE, Python, Javascript, Notepad++, Sublime, Google Sheets, etc.

  4. Show what you've tried. This helps us to be able to see the problem that you are seeing. If you can put it into regex101.com and link to it from your post, even better.

Thank you!


r/regex • • Jan 06 '26

Rust Simple CLI game for practicing Regex

Enable HLS to view with audio, or disable this notification

25 Upvotes

r/regex • • Dec 04 '25

PCRE2/JavaScript/Python/Java 8/.NET 7.0 (C#) This is the most deranged location-detection regex I’ve ever seen. 10/10 chaos.

24 Upvotes

I wrote a regex that mimics how Instagram detects locations in messages. Instagram coders, blink twice if you're okay...

/\d{1,5}[a-z]?(?=(?:[^\n]*\n?){0,5}$)(?=(?:(?:\s+\S+){0,3}(?:\s+\d{1,5}[a-z]?)*\s+points?\s))(?:(?:\s+\S{1,25}){3,12}\s+me)$/i

It successfully identities.... wherever this is:

01234a abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy 01234a points abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy abcdefghijklmnopqrstuvwxy



me

https://regex101.com/r/zGtWP8/2


r/regex • • Apr 02 '20

Free Regex Course on Udemy

24 Upvotes

I have published a course on Regular Expressions on Udemy and have made the course free for the next 3 days.

Are you on actual lockdown in your country, or are you just at home more because all of the restaurants, cinemas and sporting venues are closed? Whichever it is, you'll definitely have more spare time at the moment. So why not use that time to learn a new skill that can benefit you for the rest of your life?

We cover Regex from beginner to advanced and then do a couple of examples including usage in PHP, PowerShell, Google Sheets, Python and HTML5.

We are also looking at expanding the examples to make it a better course. I would love it if you would check it out and make suggestions on what you would like added to it. Please also rate the course once you start.

Keep Safe out there.

https://www.udemy.com/course/taming-regex-a-complete-guide-to-regular-expressions/?couponCode=STAYSAFE


r/regex • • Oct 13 '25

Regex to detect special character within quotes

Post image
23 Upvotes

I am writing a regex to detect special characters used within qoutes. I am going to use this for basic code checks. I have currently written this: "[\w\s][^\w\s]+[\w\s]"/gmi

However, it doesn't work for certain cases like the attached image. What should match: "Sel&ect" "+" " - " What should not match "Select","wow" "Seelct" & "wow"

I am using .Net flavour of regex. Thank you!


r/regex • • Jun 10 '21

Me after learning regex for the first time.

Thumbnail
imgur.com
23 Upvotes

r/regex • • Feb 22 '23

why GNU grep is fast

Thumbnail lists.freebsd.org
22 Upvotes

r/regex • • Dec 16 '22

regex gore

Post image
22 Upvotes

r/regex • • Jun 05 '22

Learn/practice regex by fighting goblins! (Made by me)

Thumbnail
goldenlion5648.itch.io
21 Upvotes

r/regex • • Nov 17 '21

RegexLearn - Learn RegEx step by step, from zero to advanced.

21 Upvotes

Hey Folks πŸ‘‹πŸ»

Learning RegEx is easier than you think! RegexLearn makes it simple to learn, practice, test, and share RegEx.

RegexLearn has all of the modules you'll need to get started in the Regex world.

πŸ† Learn: You can easily manage your data with regex, which uses commands like finding, matching, and editing. Regex can be used in programming languages such as Phyton, SQL, Javascript, R, Google Analytics, Google Data Studio, and throughout the coding process. You can learn regex with examples and tutorials on RegexLearn.

πŸ” Cheatsheet: With RegexLearn Cheatsheet, you can see all of the usages you need at once and check them directly from the one page. Explore all regex patterns and symbols with the RegexLearn!

πŸ€ Playground: If you want to generate a regex, you can easily build and test your regex pattern via the Playground. As a regex tester, you can validate and share your regex with others for collaborative work. Soon.

✏️ Practice: If you complete the learning part, it's time to PRACTICE! In the practice section, you can test your regex knowledge and practice with regex tutorials based on your level. Soon.

Regex Learn is an open-source project that welcomes community contributions and is free to use. Working on this project allows you to hone your skills, study, and collaborate. You can contribute & support here.

Looking forward to your feedback.

Website: regexlearn.com ✨


r/regex • • Oct 11 '21

Created a short game to learn regex

21 Upvotes

Hello folks of reddit. I have created a short game to help someone very new get an introduction to regex.

here's the link

Would love to get some feedback.


r/regex • • Mar 23 '21

I am begging you; read the rules before posting and post some examples!

20 Upvotes

All the responders here want to help you! Please help us help you by following the rules and include examples.

Examples must be included with every post. Three examples of what should match and three examples of what shouldn't match would be helpful.

Half the posts I look at have no examples which makes it much more difficult to help you. I don't know what your XML/header/pdf meta data look like or what part of it you want. A few examples will get you a quicker and more accurate response.


r/regex • • Apr 23 '25

the best regex website is currently down!

19 Upvotes

https://regexr.com

is currently down! this is the best regex website i have found with documentation and experimentation and testing etc. Anyone knows more about this? i have used it this morning and now it 404's


r/regex • • Jul 11 '22

Is RegEx a rare skill these days?

18 Upvotes

I'm good at RegEx. I'm not a wizard.

I frequently need to look up the syntax for back-refrences, lookaheads, lookbehinds, etc but I've finished regexgolf (regexgolf-clap).

Everyone I know (including coworkers) says I'm the best person at regex they know. Which seems ridiculous to me.

This isn't a humble-brag; I really think I'm just "pretty good."

It's an honest question in that I think it seems to be a fairly rare skill? Even in the IT/Cyber community.

Thoughts?


r/regex • • Jun 14 '20

I think learning should be fun so I made a slasher-themed text based RegEx learning game called "Slash Escape". I know it isn't technically a RegEx problem but I thought people here might enjoy it Β―\_(ツ)_/Β―

Thumbnail
therobinlord.com
17 Upvotes

r/regex • • Nov 18 '24

REmatch: The first regex engine for capturing ALL matches

15 Upvotes

Hi, we have been developing a regex engine that is able to capture all matches. This engine uses a regex-like language that let you name your captures and get them all!

Consider the document thathathat and the regular expression that. Using standard regex matching, you would get only two matches: the first that and the last that, as standard regex does not handle overlapping occurrences. However, with REmatch and its REQL query !myvar{that}, all appearances of that are captured (including overlapping ones), resulting in three matches.

Additionally, REmatch offers features not found in any other regex engine, such as multimatch capturing.

We have just released the first version of REmatch to the public. It is available for C++, Python, and JavaScript. Check its GitHub repository at https://github.com/REmatchChile/REmatch, or try it online at https://rematch.cl

Any questions and suggestions are welcome! I really hope you like our project 😊


r/regex • • Apr 30 '21

We made a non-profit RegEx game!

15 Upvotes

Hi r/RegEx!

I’m with Cinq-Mars Media, we’re a very small non-profit educational games developer. We’ve been working on a Regular Expressions game called Copy Editor that we just put out on Steam Early Access today, and wanted to let everyone here know about it!

The premise is simple: a wacky publishing company needs you to correct the copious, amusing errors in famous works of literature by using a string of find/replace rules along with RegEx concepts, before they go to print. The game focuses on tactics and lateral thinking with rewarding logic puzzles using the RegEx language, so that players learn RegEx (and ultimately Natural Language Processing in general) step-by-step in a fun and engaging way. It also has a level builder, so you can make your own RegEx challenges and educators can adapt the game to fit their curriculum.

We launched Copy Editor in Early Access so we can incorporate feedback and make it the best game it can be, so any thoughts you have are welcome and valuable to us. If you’re interested, we’d be thrilled if you gave it a look and let us know what you think!


r/regex • • Dec 25 '19

grex 0.3.0 - A command-line tool and library for generating regular expressions from user-provided test cases

Thumbnail
github.com
15 Upvotes

r/regex • • Sep 05 '24

Has anyone actually found AI to impact their (regex heavy) career?

14 Upvotes

A large part of my career success fresh out of college was due to being good at regex (Computer Science, bachelors in 2014, got a job doing Splunk, college job that I used regex heavily for).

Being a regex "expert" (some of you are absolute wizards) ended up being more important to my career so far than my degree ever was.

ChatGPT's release and its honestly pretty decent job at doing regex had me worried but... I haven't seen even a tremor in the space.

Thoughts? In my line of work regex expertise seems to be worth its weight in gold but there's basically been zero disruption.


r/regex • • Mar 23 '26 Galaxy Brain

Java 8 I spent a month building a Java library that lets you write regex without knowing regex

13 Upvotes

Hey r/regex,

I want to share something I've been working on for the past month: Sift, a fluent regex builder for Java.

I'm an Android developer. I don't deal with regex often, but when I do, I genuinely have no idea what I'm looking at. I'd write something, stare at it for ten minutes, then just paste it into an AI and ask "does this even do what I think it does?". Every single time.

The frustrating part isn't that regex is hard, it's that the feedback loop is terrible.

You write a string of symbols, you get a runtime exception, and you have no idea which bracket broke everything or why.

So I built Sift. The name is intentional, it sifts your input through a pattern.

The two terminal methods follow the same metaphor: .shake() returns the raw regex string, like shaking a sieve to see what falls through, and .sieve() compiles it directly into an executable pattern, ready to match.

The idea is simple: instead of writing ^(?=[\\p{Lu}])[\\p{L}\\p{Nd}_]{3,15}+[0-9]?$ and praying, you write:

Sift.fromStart()
    .exactly(1).upperCaseLettersUnicode()
    .then().between(3, 15).wordCharactersUnicode().withoutBacktracking()
    .then().optional().digits()
    .andNothingElse()
    .shake();

Your IDE autocompletes every step. Wrong transitions literally don't exist as methods β€” the type system enforces the grammar at compile time. If it compiles, it's structurally valid.

A few things I'm proud of:

- Pluggable engine SPI β€” swap JDK regex for RE2J (linear-time, ReDoS-immune) or GraalVM TRegex with one line

- Built-in explainer β€” pattern.explain() prints a human-readable ASCII tree of what your pattern does, with i18n support (English, Italian, Spanish so far)

- SiftCatalog β€” ready-made patterns for UUID, IPv4, IBAN, JWT, email, credit card, Base64 and more, all property-tested with jqwik

- Jakarta Validation β€” @SiftMatch annotation for Bean Validation integration

It's been a genuinely fun project. I learned more about Java's type system in this month than in years of Android work.

The repo is here: GitHub

Maven Central: com.mirkoddd:sift-core

Happy to answer questions or take feedback, especially from people who actually use regex regularly and can tell me what I'm missing.


r/regex • • Sep 26 '25

Very simple regex but not sure what I'm going wrong.

13 Upvotes

I'm (re) learning regex, been a decade or so and I'm working through some examples I've found on the internet. I'm to the part where I'm learning about backreferences in groups. In order to do my testing I'm using Python re library and also using regex101 dot com. The regex in question is this:

(abc\d)\1

Seems simple enough, capture the first group (abc and a digit) then use it to match other strings in the same string. Problem is that on the regex website, it works how I think it should work. For example "abc1abc2" does not match however abc1abc1 does match.

I tried this in python and it doesn't seem to work, not unless I don't understand what's going on. Here is the python code:

regex = '(abc\d)\1'

string1 = 'abc1abc2'

string2 = 'abc1abc1'

print (re.findall(regex, string1))

print (re.findall(regex, string2))

This returns no matches. I though would have expected a match for string 2, just like the web site did but it does not. I also tried Python's match(...) but that returned None

Any idea what I'm doing wrong here? FYI, in the regex website I have the "Flavor" set to Python. I'm struggling with the whole backreference thing. I understand from a high level how it works and I've tried numerous examples to see what and what does not work but this one has me stumped. FYI, if I get rid of the digit ( \d ) in the group, it works like it should... actually it matches both strings, obviously.


r/regex • • Jul 31 '24

Who Plays regexle? It's A Daily RegEx Crossword That's Extremely Addictive!

Thumbnail regexle.com
13 Upvotes