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

<answer>

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

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

-23 points

Hot take: You’re shit at coding if you can’t do regex.

permalink
report
reply
6 points

Regex should generally be avoided wherever possible.

permalink
report
parent
reply
13 points

Yeah but it’s just so tempting… It validates so many inputs so easily…

permalink
report
parent
reply
12 points

And misses others you didn’t think about.

permalink
report
parent
reply
19 points
*

Ah yes, spoken like a true elitist asshole

permalink
report
parent
reply
0 points

It takes a couple of hours to learn the basics.

permalink
report
parent
reply
3 points

And then a few more any time you actually want to use it.

And then double it each time you have to decipher the existing one

Just don’t use regex unless there is really no other way, and when you absolutely have to - frankly, that’s one of the ultra rare occasions I recommend using the AI.

permalink
report
parent
reply
11 points

Regular expressions in general, and automata theory, sure you should know about that. But a specific extended regex language like here? That’s like saying you’re shit at coding if you can’t do <insert arbitrary programming language here>.

permalink
report
parent
reply
-2 points

All my homies hate regexs. That’s actually the best use case I found for LLMs so far : I just tell it what I want it to match or not match, and it usually spits out a decent one

permalink
report
reply
6 points

Oooof. I feel like trying to figure out what’s wrong with some regex I didn’t write is much harder than writing it myself personally.

permalink
report
parent
reply
1 point

I’ve never had to use it for important stuff tbh. But alongside a regex tester and a sample of the stuff I intend to use it on, I’ve had good results with an incremental approach where I tell the LLM what I want to change with the expression until I’m satisfied

permalink
report
parent
reply
3 points

That sounds…

Easier to get almost right than actually learning the subject.

Much, much harder to get completely right than actually learning the subject.

So yes, basically the archetypal use case for LLMs.

permalink
report
parent
reply
3 points

Empty input Or input of exactly 1 character Or input of at least 2 characters, followed by at least 1 something (idk what \1 matches)

Did I get it (almost)?

permalink
report
reply
1 point
*

\1 is group 1 which is inside (), so second part is repeated 2 or more times of 2 or more char.

permalink
report
parent
reply
1 point

Interesting.

So that means match any string that is made entirely of a single repeating sequence, where repititon is possible.

permalink
report
parent
reply
3 points

It matches “yo momma”.

permalink
report
reply
43 points

no

permalink
report
reply
2 points

that is correct!

permalink
report
parent
reply
1 point

nononono

permalink
report
parent
reply

Programmer Humor

!programmerhumor@lemmy.ml

Create post

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

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.

Community stats

  • 5.3K

    Monthly active users

  • 884

    Posts

  • 8.9K

    Comments

Community moderators