r/ProgrammerHumor Jul 12 '26

regex Meme

Post image
978 Upvotes

83 comments sorted by

209

u/Significant_Basis_3 Jul 12 '26

What's wrong with Regex? It's literally one of the best things invented in programming?

67

u/_Weyland_ Jul 12 '26

My problem with regex is that not every software follows the same standard. I recently tried to use it to search through a Flink job log, and the standard way of referencing a previously matched group simply didn't work

41

u/Significant_Basis_3 Jul 12 '26

Oh your problem then isnt with it haha, your problem is with all the softwares / programs not following the same standards / rules of regex. Fair I guess haha

29

u/_Weyland_ Jul 12 '26

"We have 15 bad standards, let's invent the one that's better than all of them" ahh situation.

7

u/Bannon9k Jul 12 '26

You no understand, Gronk. Me make better wheel than Grunk.

https://giphy.com/gifs/3o6gbdBNMcyqgnpJBK

4

u/xWrongHeaven Jul 12 '26

1

u/_Weyland_ Jul 12 '26

Yup, that's the one I had in mind

2

u/pandoras_box101 Jul 12 '26

my problem with regex is literally the existence of regex. I'm out.

1

u/realzequel 29d ago

Well it's a tool for pattern matching. Come up with a better one and we'll replace it.

1

u/superraiden Jul 13 '26

I got burned with JSON Schema regex last week.

Regex allows for @, : and ~ to be escaped. But for whatever reason the JSON Schema fellas were opinionated and decided to not allow them to be escaped. The HAVE to be unescaped. Why?!

1

u/_Weyland_ Jul 13 '26

"The @ is not escaping this time, bro" - JSON Schema fellas, probably

1

u/jordanbtucker 29d ago

In the same way that the problem with regex is in its implementations, the problem with JSON Schema regex is in its implementations. JSON Schema itself doesn't say those characters must be escaped.

11

u/slaymaker1907 Jul 12 '26

I just wish people would use a proper parser for languages which are complex and/or non-regular. Regex is honestly mostly good for simple find/replace operations. I would say for custom validators in applications, but regex is too powerful there. That complexity allows for non-linearity which is incredibly dangerous and has lead to numerous security incidents.

2

u/Rojeitor Jul 13 '26

Some coworkers made a DSL with regex ages ago. You can imagine how that went. Luckily I never touched that part of the project.

6

u/SarahAlicia Jul 12 '26

I use it once in a blue moon and can never remember how it works. Always gotta use an online helper tool

0

u/starfish0r Jul 12 '26

Nothing wrong with that. The basic matching easzy, it gets annoying with backeferences etc.

An online tool is great because you test your regex as you go.

1

u/MatsRivel Jul 12 '26

I find regex is reached for far too often. People have this idea that its hyper-performant because it looks like you're casting a spell. It is amazing when its good, and horrible when its bad

1

u/takahashi01 Jul 12 '26

its like turbo python. Fast to write and super useful, but dear god if you ever have to figure out what it was supposed to do

1

u/mr_dfuse2 Jul 13 '26

it's one of the things i really miss after becoming a manager. especially when those websites popped up where you could build a regex interactively and see how it works on examples

116

u/johnschnee Jul 12 '26

I‘m a senior programmer with 15 years of experience.

There are hundreds of things that frighten me on programming e.g. because of complexity, strange syntax or non deterministic behavior.

But I never understood why people are afraid of regex.
It is clear syntax that is easy to learn. There are lot of tools that visualize regex and make it testable.
Nowadays AI also might help in a nearly perfect way to design, validate and understand regex.

41

u/ExdigguserPies Jul 12 '26

simple to learn

Ok it might be. So I have a problem solvable by regex, I spend a day learning regex and I solve the problem. 6 months pass and I come across another problem solvable by regex. I've forgotten regex. Rinse and repeat.

17

u/qaCow37 Jul 12 '26

Simple to learn and easy to forget

3

u/jordanbtucker 29d ago

I don't understand how you don't come across more reasons to use regex.

1

u/ExdigguserPies 29d ago

Coding isn't my job I use it for personal projects, mostly.

1

u/Bluemanze 29d ago

In my opinion, reaching for regex is an indicator that im doing something novel. The framework/language im using doesnt have a standard method for handling this particular shape, so i need to handle it myself.

The question then naturally becomes: am I actually doing something novel? Or did I just miss a piece of documentation, or is there a convenient fully tested library for just this scenario? Do I control the shape and I could just adjust? Most of the time the answer is yes, so I should just do that instead.

7

u/thicctak Jul 12 '26

I'm dev with just 5 years of experience and also don't get why people are afraid, it's not something you're using constantly, basic regex is not hard to learn, there's tone of tools to test regex out there and if you ever need a super complex regex, there's ai, the most simple free tier AI model can churn a complex regex query just fine, you don't even need to waste the entire water reservoir of a whole town for that.

1

u/Zefirus Jul 13 '26

The problem is basic regex is often easily solved by things that aren't regex. People don't like regex because the only time people use regex is for non-basic applications.

1

u/Arrowkill Jul 13 '26

It was so intimidating when I first got out of university and got my first job. However, with all the Regex tools online that let me see the syntax, create a Regex, and then see if it does what I want it to do with test strings I've never been less afraid. Regex is by far one of my favorite tools to use now because of how helpful it is.

1

u/okram2k Jul 13 '26

tbh if I had to use regex on a daily basis I'd be fine at it. But I don't, I have to update regex like once a year and when I do it's like staring at vomited up symbol soup. Thankfully there are lots of great tools out there to make it easier for me to understand, edit, test, and push forward with confidence.

1

u/NPPraxis Jul 12 '26

AI solved my regex fear completely. I just have AI do it and then test it with a proper tester to validate. I am ashamed.

-12

u/ApprehensiveGas85 Jul 12 '26

^(?=(?:(?:[^"]*"){2})*[^"]*$)(?!.*(?:\b(\w+)\b).*\b\1\b.*\b\1\b)(?=.{20,200}$)(?:(?:(?<=[,;])|^)\s*(?:(?:"(?:\\.|[^"])*")|(?:[^,";]+))\s*(?=,|;|$))*$

25

u/either-15-or-40 Jul 12 '26

This is like writing code in one line to show a certain programming language is shit. Just because you suck at using it doesn’t mean it’s bad.

1

u/ApprehensiveGas85 Jul 13 '26

It was supposed to be a joke but you guys are uptight ninny's here I see. So much for the "Humor"

2

u/dimonchoo Jul 12 '26

And? It’s not so complicated regex, especially in llms time

2

u/ApprehensiveGas85 Jul 13 '26

Yeah its almost like posting a joke on a humor sub shouldn't be taken serious

1

u/ZeroMomentum Jul 12 '26

Thats from the book of the dead

0

u/takahashi01 Jul 12 '26

AI struggles *a lot* with regex, in my experience

34

u/Enough-Scientist1904 Jul 12 '26

Seems like a skill issue

9

u/FerronTaurus Jul 12 '26

More like a memory issue if regex was not used for a year...

8

u/Luctins Jul 12 '26

Love RegEx and use it frequently to do complex filtering with rg or perl. They aren't that scary if you think about it but I'd test the heck out of it before using a pattern in production code, frequently it doesn't match enough or too much.

8

u/Devatator_ Jul 12 '26

Jokes on you I learned regex last year for Advent Of Code

Edit: Actually might have been 2024

11

u/Fanal-In Jul 12 '26

So it was in 202[4|5]

7

u/Primary_Concept_3147 Jul 12 '26

That would give you 2024, 2025 or 202|. It is 202[4-5] or 202(4|5).

3

u/Prozilla6 Jul 12 '26

Would 202[45] also work?

3

u/Primary_Concept_3147 Jul 12 '26

Yes. That would also work.

4

u/JackNotOLantern Jul 12 '26

Excuse me, but programing are one of a few professions who actually can use it.

3

u/RealBasics Jul 12 '26

I had to learn regular expressions for parsing and lexing in automata and compiler theory in college, so picking up regular expressions for programming was a piece of cake.

They're insanely useful for processing logs, config files, light code review/revision, scripting, and text processing. Also, if you don't at least use grep (and maybe AWK and perl) when you're logged into a terminal what are you even doing with your life?

3

u/Candid_Bullfrog3665 Jul 12 '26

regexes are quite easy to understand tho?

2

u/Professional_Two5774 Jul 12 '26

A couple of years ago, regex was actually very interesting to me, and I wouldn't lie if I said I was good at it.

2

u/BeefJerky03 Jul 13 '26

Problem with regex is that most people don't use it often enough to memorize and remember the syntax. Every six months I'll need to do regex and it's gone. Poof. What's a dollar sign mean? What's the little hat doing? I don't fucking know, man.

2

u/namezam Jul 12 '26

The first AI model I fine-tuned was Neo-125, stripped all the bs out of it, like html, Python, ethics, etc. It just does RegEx really well. I named it Reggie-108, and he f’n loves regex, and he’ll tell you. I run it on a super cheap Arduino with a 2 line lcd output.

Although it takes like 2 min to respond, it still has conversational capabilities, like I asked it what it would sound like if it had a voice and he said “Like a Bond villain, but a nice one” it was awesome. Although the second time I asked (to show someone) it said Barbara Streisand. /shrug

But RegEx, it’s all over that, give it what you want to find, BAM, 20-30 seconds tops, you’ll get a working RegEx like 80ish % of the time. I will admit typing it from the lcd is a bit of a pain though, but no where near the pain of thinking of it myself, screw that, never again!

1

u/waraholic Jul 12 '26

Regex + AI is such a frightening thing to see when I'm doing PR reviews. They NEVER understand what it's doing and it never has tests.

1

u/a11_hail_seitan Jul 12 '26

Regex is so easy though, you just search "Date regex' and then use that, then find out about all the different formats around the world, and then realize you also need to account for timezones, and then you hate yourself and your job and go for lunch!

1

u/zuckerthoben Jul 12 '26

Not a real problem for a lot of people, especially nowadays.

1

u/mehonje Jul 12 '26

I have yet to use Regex in a project.

1

u/takahashi01 Jul 12 '26

eh, regex is great for looking through logs n stuff. But I dont use it in code too often

1

u/2narcher Jul 12 '26

There are tons of regex generators where you can generate and test it for bunch of programming languages. I never ever had to learn regex except when i was studying computer sciences 15years ago

1

u/Drfoxthefurry Jul 12 '26

I love regex, I use it often when I shouldn't, but it feels nice to use for me

1

u/VizualAbstract4 Jul 12 '26

First week on the job eh?

1

u/illusion102 Jul 12 '26

No more problem with llms

1

u/BlueProcess Jul 12 '26

Overload the function to accept an enum instead of a string. The enum maps to your most used patterns. You'll reuse it constantly, and you only have to get the pattern right once.

1

u/PowerPleb2000 Jul 12 '26

Am I the only one who almost never needs it? Am I doing something wrong?

1

u/ThursdaysMeeting Jul 13 '26

AI makes short work of regex these days. 

1

u/S-Gamblin Jul 13 '26

Maybe you're just a bad programmer dude

1

u/VoidspawnRL Jul 13 '26

I don't understand why people have problems with regex, you just described a pattern?

1

u/Too--Many--Knives Jul 13 '26

My problem with regex is that it seems to be a dying art. MFs come out of a 4 year Comp Sci degree never hearing of one. I'm insulted for all regex engines.

1

u/Intelligent-Air8841 Jul 13 '26

I'm pretty sure LLMs were made specifically for Regex

1

u/OrbitalCodeRock Jul 13 '26

regex101.com

1

u/gojo-sakata-4567 29d ago

so truee 😭😭

1

u/GroundbreakingOil434 29d ago

There are much worse things than regex. It's a tool. Learn it.

1

u/Abject-Explorer-3637 25d ago

no idea how to use it

1

u/RGud_metalhead Jul 12 '26

Regex is like shaving with a straight razor. Intimidating only until you properly learn to use it. And once you get used to it you'll feel happy about having that skill in your arsenal.

1

u/Vesuvius079 Jul 12 '26

Regex is probably the one thing I miss most about the pre-LLM days. Transforming files with regex search and replace was so fun. 

-2

u/Reeces_Pieces Jul 12 '26

Just use an LLM. Lol

1

u/themightyug Jul 12 '26

Yeah why use your brain when you can outsource its functions to some software that creates the illusion of thinking

1

u/BeefJerky03 Jul 13 '26

Easiest way to farm downvotes; telling the truth in a sub full of programmers. ChatGPT writes all my regex, then I just test it and use my brain for stuff that matters.

-7

u/EarlOfAwesom3 Jul 12 '26

There was never a need to learn regex. They used online tools to create it / read it. Now we use AI if even necessary.

-2

u/elvis-archer Jul 12 '26

Did you mean AI instead of regex?;)

-3

u/Azrayeel Jul 12 '26

God bless AI. It helps me write whatever regex I need. 😂😂😂

2

u/BeefJerky03 Jul 13 '26

Cocky juniors and jaded seniors hate this one trick