The Enchanted Tavern
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@NateNate60@lemmy.world to Programmer Humor@lemmy.ml •
edit-2
7 months ago

Oh boy what a beautiful regex. I’m sure it does something logical and easy to understand.

lemmy.world

message-square
106
fedilink
339

Oh boy what a beautiful regex. I’m sure it does something logical and easy to understand.

lemmy.world

@NateNate60@lemmy.world to Programmer Humor@lemmy.ml •
edit-2
7 months ago
message-square
106
fedilink

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

<answer>

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

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

alert-triangle
You must log in or register to comment.
  • @yrmp@lemmy.world
    link
    fedilink
    6•7 months ago

    Regex should generally be avoided wherever possible.

    • @NateNate60@lemmy.worldOP
      link
      fedilink
      13•7 months ago

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

      • @yrmp@lemmy.world
        link
        fedilink
        12•7 months ago

        And misses others you didn’t think about.

        • @gwilikers@lemmy.ml
          link
          fedilink
          6•7 months ago

          Yeah, I’ve found myself wasting quite a lot of time thinking of the ‘perfect regex’ for task X only to realise that I could have avoided doing so by simply taking a different approach.

Programmer Humor@lemmy.ml

!programmerhumor@lemmy.ml
Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

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.
  • 15 users / day
  • 110 users / week
  • 185 users / month
  • 1.59K users / 6 months
  • 1 subscriber
  • 1.59K Posts
  • 29.7K Comments
  • Modlog
  • mods:
  • @AgreeableLandscape@lemmy.ml
  • @cat_programmer@lemmy.ml
  • UI: unknown version
  • BE: 0.18.2
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org