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.
View all comments
83
comments
Is there a reason to use
(..+?)
instead of(.+)
?4 0 ReplyYes, the first one matches only 2 more characters while the second matches 1 or more. Also the +? is a lazy quantifier so it will consume as little as possible.
5 0 ReplyAh, didn't know +? was lazy, thanks
3 0 ReplyI thought, the +? was going to be a syntax error. 🙃
3 0 ReplyI was like, why specify "one or more" and then make it optional? Isn't that just .*?
3 0 Reply
You've viewed 83 comments.
Scroll to top