this post was submitted on 14 Feb 2025
888 points (98.5% liked)

Programmer Humor

20689 readers
839 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
(page 2) 23 comments
sorted by: hot top controversial new old
[–] [email protected] 85 points 1 week ago* (last edited 6 days ago) (13 children)

I found your email address:

(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
[–] [email protected] 51 points 1 week ago (1 children)

HOWD YOU GET MY PASSWORD?!?

load more comments (12 replies)
[–] [email protected] 31 points 1 week ago (3 children)

It helps if you break it apart into its component parts. Which is like anything else, really, but we've all accepted that regexes are supposed to run together in an unreadable mess. No reason it has to be that way.

[–] [email protected] 17 points 1 week ago (1 children)

If they are Perl regexes, like all regexes are supposed to be, you can have non-semantic whitespace and comments.

But if you are using some system that enforces something different, you are out of luck.

[–] [email protected] 6 points 1 week ago

Not necessarily. For just debugging purposes, you can still break them up to help understand them. Even ignoring that, there are options in languages that don't implement /x.

https://wumpus-cave.net/post/2022/06/2022-06-06-how-to-write-regexes-that-are-almost-readable/index.html

[–] [email protected] 10 points 1 week ago (1 children)

At my company we store our regex in the database with linebreaks in it, but when it's actually called to be used those line breaks are stripped out. That way regex that looks for X can all be all on one line and actually readable.

[–] tyler 10 points 1 week ago (2 children)

wait... why do you have so many regexes you need to put them in a database???

load more comments (2 replies)
[–] [email protected] 5 points 1 week ago

The comments flag needs more support.

[–] [email protected] 27 points 1 week ago (2 children)

I have found chatgpt to be very good at writing regex. I also don't know how to write regex.

[–] [email protected] 16 points 1 week ago

In my experience, it is good at simple to medium complexity regex. For the harder ones it starts being quite useless though, at best providing a decent starting point to begin debugging from.

load more comments (1 replies)
[–] [email protected] 21 points 1 week ago (1 children)
[–] [email protected] 31 points 1 week ago (1 children)
[–] echindod 4 points 1 week ago

This is the one I use! Might have to look at regexer though

[–] [email protected] 12 points 1 week ago (16 children)

Never debug regex, just generate a new one. It's not worth the hassle to figure out not only what it does, but what it was meant to do.

Better yet, just write it out in code, and never use regex. Tis a stupid thing that never should have been made.

load more comments (16 replies)
[–] verstra 9 points 1 week ago* (last edited 1 week ago)

If I have a complex regular expression to code into my app, I write it in pomsky, then copy paste the compiled regex to my source file, but also keep the pomsky source nearby. Much more maintainable.

[–] [email protected] 8 points 1 week ago* (last edited 1 week ago) (1 children)

This is basically code refactoring on a simplified level. You're basically renaming a whole bunch of functions/tokens at once.

Let's say you're renaming the variable 'count' under the method 'buttplug'. First off, what do you rename it to?

You start by replacing every instance of buttplug.count with a unique token, let's say tnuoc.gulpttub.

Then you replace that buttplug with a unique buttplug.

Simple.

load more comments (1 replies)
[–] [email protected] 7 points 1 week ago

There are a few online regex testing tools that will analyse your efforts and give you the opportunity to provide sample data.

[–] [email protected] 6 points 1 week ago

Ohhhhh it was this extra '

[–] [email protected] 2 points 1 week ago

I think he found the Road Runner.

[–] [email protected] 1 points 1 week ago (1 children)

This would honestly be a lot easier

[–] echindod 2 points 1 week ago

I don't know any hieroglyphs, but I do know cuneiform. Would rather read cuneiform than regex!

load more comments
view more: ‹ prev next ›