this post was submitted on 31 Oct 2024
329 points (97.7% liked)

Programmer Humor

32561 readers
361 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

^.?$|^(..+?)\1+$

Matches strings of any character repeated a non-prime number of times

https://www.youtube.com/watch?v=5vbk0TwkokM

you are viewing a single comment's thread
view the rest of the comments
[–] taiyang@lemmy.world 10 points 3 weeks ago (1 children)

Thanks, I now have insight into my own personal hell for when I die.

[–] fubo@lemmy.world 11 points 3 weeks ago (1 children)

Regex is good for a few very specific things, and sysadmins used to use it for goddamn everything. If all your server logs are in lightly-structured text files on a small number of servers, being able to improvise regex is damn useful for tracking down server problems. Just write a shell loop that spawns an ssh logging into each server and running grep over the log files, to look for that weird error.

These days, if you need to crunch production server logs you probably need to improvise in SQL and jq and protobufs or systemd assmonkery or something.

But if you actually need a parser, for goodness sake use a parser combinator toolkit, don't roll your own, especially not with regex. Describing your input language in plain Haskell is much nicer than kludging it.

(This is the "totally serious software engineering advice" forum, right?)

[–] taiyang@lemmy.world 2 points 3 weeks ago

I've worked mostly as a data scientist / analyst but regex was being user to identify various things in the SQL database (which was viewed locally via R table). I forget the exact is cases, mostly remembering how complex some of it got... Especially after certain people were using GPT to build them.

And GPT like to make up extra bits not necessary, but my coworkers didn't exactly have the knowledge to read regex, which lead to nobody really checking it. Now it just gives me anxiety, haha.