Pricefield | Lemmy
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@[email protected] to Programmer [email protected] •
edit-2
8 months ago

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

lemmy.world

message-square
83
fedilink
320

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

lemmy.world

@[email protected] to Programmer [email protected] •
edit-2
8 months ago
message-square
83
fedilink

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

<answer>

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

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

  • @[email protected]
    link
    fedilink
    11•8 months ago

    Regex should generally be avoided wherever possible.

    • @[email protected]OP
      link
      fedilink
      11•8 months ago

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

      • @[email protected]
        link
        fedilink
        11•8 months ago

        And misses others you didn’t think about.

        • @[email protected]
          link
          fedilink
          5•8 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 [email protected]

[email protected]
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: [email protected]

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.
  • 24 users / day
  • 76 users / week
  • 400 users / month
  • 1.56K users / 6 months
  • 4 subscribers
  • 1.81K Posts
  • 38.4K Comments
  • Modlog
  • mods:
  • @[email protected]
  • @[email protected]
  • UI: 0.18.4
  • BE: 0.18.2
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org