Oh boy what a beautiful regex. I'm sure it does something logical and easy to understand.
Oh boy what a beautiful regex. I'm sure it does something logical and easy to understand.
^.?$|^(..+?)\1+$
<answer>
Matches strings of any character repeated a non-prime number of times
You're viewing a single thread.
Syntactically valid Perl
24 0 ReplySomething 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"!<
10 0 ReplyYou're misreading the
..+?
part. That means 2 or more characters, non greedy.8 0 ReplyIt's a line with a sequence of two or more characters repeated at least twice.
4 1 ReplyOnly the part after the pipe character. The pipe character works as an "or" operator. RegalPotoo is right.
4 0 ReplyThey 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".
3 0 ReplyI agree, you're right about the part after the pipe and RegalPotoo's explanation was not entirely correct.
4 0 Reply