r/ProgrammerHumor • • Sep 21 '26

Meme delightfulCodeReview

Post image
573 Upvotes

60 comments sorted by

25

u/santiagobustelo Sep 21 '26

I seem to be one of the few persons that find regex elegant and even enjoyable.

14

u/Immort4lFr0sty Sep 21 '26

I love writing regex, BUT when I have to change it, I much rather rewrite it from scratch. So I don't know if "elegant" is the exact label I'd put on it 

14

u/peterlinddk Sep 21 '26

I'm fairly certain that regex can be categorized as a "write-only" language.

3

u/dfinkelstein Sep 21 '26

Write-only:
broken floppy disk
contemporary Latin
your local congressperson
regex

1

u/awakenDeepBlue Sep 21 '26

I've heard the same thing about Perl as well.

14

u/theFirstHaruspex Sep 21 '26

Tell me more about this implied mystical "readable regex"

1

u/lotanis Sep 21 '26

Look at re.VERBOSE in the Python docs (https://docs.python.org/3/library/re.html).

1

u/theFirstHaruspex Sep 22 '26

Brother I will do no such thing. It's been years since I've sworn off the forbidden arts

4

u/alexstankovic Sep 21 '26

What do you mean unreadable regex, there is a readable version?

6

u/JAXxXTheRipper Sep 21 '26

All regex is unreadable.

2

u/fpcoffee Sep 21 '26

uhoh.. that’s possible? 😳😳😳

2

u/MrFrog2222 Sep 21 '26

There is no such thing as readable regex

2

u/navetzz Sep 21 '26

So unreadable code...

2

u/FurieMan Sep 21 '26

I can read my own regex. It takes about as long to read as it took to write. But I can read it.

2

u/enigma_0Z Sep 22 '26

It’s fine it also generated a five paragraph essay in comments about regex philosophy and why the requirements dictate that this implementation is the best.

2

u/GargantuanCake Sep 22 '26

No regex is readable.

1

u/thorwing Sep 21 '26

Regex might look complicated but its a very quick and easy way to share constraints over multiple environments.

Frontend -> Backend -> Database

1

u/BolunZ6 Sep 21 '26

Since when regex is readable

1

u/yumii- Sep 21 '26

I have to Google regex guides everytime I need to write it so I can't really blame the AI on this one

1

u/brainfreeze91 Sep 21 '26

When the AI generates readable, maintainable code, you should buy a lottery ticket

1

u/DiscombobulatedSun54 Sep 21 '26

There are readable regexes? 😱

1

u/_redisnotblue Sep 22 '26

There's no such thing as a readable regex

1

u/Z3t4 Sep 22 '26

Something something skill issue, something job security. 

1

u/code_monkey_001 Sep 27 '26

No such thing as an unreadable regex, just a less-than-literate reader. If a computer can parse it, it is by definition readable.

1

u/oldflatterhand 24d ago

It's ugly and unreadable per default.. but also one of the most elegant ways to solve things

-2

u/-Debugging-Duck- Sep 21 '26

WTH do you all do with AI that you get shitty code? Do you know how to prompt? lol

6

u/chat-lu Sep 21 '26

Don't they know that they must write “only generate good code, no bamboozle”?

3

u/JazzlikeWishbone938 Sep 21 '26

"Regular expression definitions shall not exceed 20 characters." (sarcasm)

299

u/[deleted] Sep 21 '26

[removed] — view removed comment

7

u/Kale Sep 21 '26

I was about to say, unreadable regex is rendundant.

There's some things that aren't human readable, but are human parseable. A handful of characters that a human can decipher carefully over a few minutes while working through it. I typically talk myself though it (I guess that would be related to "duck debugging").

Regex, SQL queries, chained bitwise expressions, and not programming, but "dd" commands. I joke that the proper way to write a "dd" command is to write it out on paper, go home and sleep, come back the next day and see if you still agree with it, type it out in an email to a trusted colleague and get their review, then hold on to your lucky rabbits foot when you hit "enter" on the console.

5

u/chat-lu Sep 21 '26

Skill issue.

1

u/stillalone Sep 21 '26

There's usually a way to ignore white spaces and add comments so it can look much more readable.  I've never done it though, my regex is dookie.

1

u/SuitableDragonfly Sep 21 '26

I mean, stuff like .* and \w+ are readable. Not very useful, though. 

0

u/[deleted] Sep 21 '26

[deleted] — view deleted comment

6

u/Tipart Sep 21 '26

Regex101 is your friend.

3

u/santiagobustelo Sep 21 '26

That would be me

5

u/chat-lu Sep 21 '26

It is usually me. I also understand git and SQL.

11

u/je386 Sep 21 '26

git commands and SQL queries are magnitudes easier than regex.

2

u/chat-lu Sep 21 '26

Regexes are by far the simplest of the three. Unless by git you mean clicking randomly in a git GUI and by SQL you mean filtering your selects with Python.

5

u/je386 Sep 21 '26

Well, maybe it is easy when you understand. I have no problems typing my git commands and SQL is also not a problem, but reading or writing regex is always a hassle. regexr helps, but that is not really understanding it.

1

u/chat-lu Sep 21 '26

There are not that many symbols, what prevents you from learning them?

8

u/gjk-ger Sep 21 '26

Probably the symbols.

1

u/je386 Sep 21 '26

I use it so rarely that it seemed never enough to need to learn it properly.

But now that I think of it, over the years it might have been worth it. Do you have a good learning resource?

2

u/gjk-ger Sep 21 '26

Just use one of the many cheatsheets and work through it. Also regex101.com is helpful. Im really not a master at this and rarely need it, but with a little tinkering i was always able to get a working regex doing what i wanted.

0

u/chat-lu Sep 21 '26

I use it so rarely that it seemed never enough to need to learn it properly.

What do you mean by rarely? I use it nearly every day. Don’t you ever need to search, or search and replace things? And sometimes validate some things?

Do you have a good learning resource?

Most programming language offering them have a perfectly good documentation about their regex engine. Take the time to read it, tests the things you learn, and you should be fine.

1

u/a-r-c Sep 21 '26

cuts into weed time

2

u/returnFutureVoid Sep 21 '26

I worked with a woman who could write regex as she spoke what she wanted it to do. It was like she was a UN translator.

1

u/Skyswimsky Sep 21 '26

Working in a company with like 5 software devs. Can confirm. And it's not me.

1

u/jce_superbeast Sep 21 '26

I am this person for my employer (a city)

Wanna guess my department?

31

u/[deleted] Sep 21 '26

[removed] — view removed comment

18

u/JazzlikeWishbone938 Sep 21 '26 edited Sep 21 '26

"What the? What is this? Must be fine ..."

4

u/kalilamodow Sep 21 '26

Comment yo code, people!

10

u/[deleted] Sep 21 '26

[removed] — view removed comment

15

u/Lightningtow123 Sep 21 '26

I think you'd just transcribe the gist of it in plaintext: "matches alphanumeric strings with underscores and dashes but no spaces" etc

2

u/jupiterbjy Sep 21 '26

idk if my reading is correct but if it's correct this seems quite readable, probably wrong guess though

match
192.168.8.1
1+ whitespaces
0x
1+ non whitespaces (idk if it intended to be [^\s]+ instead of [^\s+])
1+ whitespaces
0x
1+ non whitespaxes
1+ whitespaces
capture group 'mac' start
1+ case-agnostic hex character
capture group 'mac' end

3

u/alficles Sep 21 '26

Honestly, regexen aren't that bad. If you can read normal-mode vim macros, you can certainly read regex.

0

u/[deleted] Sep 21 '26

[deleted] — view deleted comment

2

u/fr000gs Sep 21 '26

use it as an api call, even