• bitjunkie@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    For a second I thought I was still in the thread about monkeys face-rolling typewriters until the heat death of the universe not eventually producing Hamlet

    • RegalPotoo@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      9 months ago

      Something like

      !“A line with exactly 0 or 1 characters, or a line with a sequence of 1 or 3 or more characters, repeated at least twice”!<

          • NateNate60@lemmy.worldOP
            link
            fedilink
            arrow-up
            0
            ·
            9 months ago

            They said—

            A line with exactly 0 or 1 characters, or a line with a sequence of 1 or 3 or more characters, repeated at least twice

            Note—

            …or a line with a sequence of 1 or 3 or more characters, repeated at least twice

            It should be—

            …or a line with a sequence of 2 or more characters, repeated at least twice

            The regex in the post will match “abab”. Their original description (line 2 of this comment) will not match “abab”.

  • Sylvartas@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    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

    • BluesF@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      9 months ago

      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.

    • kibiz0r@midwest.social
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 months ago

      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.

  • nroth@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    A non prime number of times… It looks like the string of characters could repeat number of times because the whole capture group repeats. I don’t see a prime constraint.

    • Feathercrown@lemmy.world
      link
      fedilink
      English
      arrow-up
      0
      ·
      9 months ago

      The capture group must be the same each time it repeats, so the number of characters stays the same. So X groups of Y characters = string of length X*Y. X and Y can be anything so any string length that can be made by multiplying two numbers-- which is every non-prime string length-- is matched. 0 and 1 are handled specially at the start.

  • fysihcyst@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    9 months ago

    This is brilliantly disgusting.

    Literal interpretation of the regex

    The regex matches either a line with a single character or a line with a sequence of two or more characters that’s repeated two or more times. For some examples: the regex matches “a”, “b”, “abab”, “ababab”, “aaaa”, and “bbbbbb”, but does not match “aa”, “bb”, “aaa”, “ab”, “aba”, or “ababa”.

    Hint for the special thing it matches

    For a line with a single character repeated n times, what does matching (or not matching) this regex say about the number n?