One of my favorite regular expression parlor tricks is this regular expression which matches collections with a prime number of elements in it.

/^(?!(.{2,})\1+$).+/

https://regex101.com/r/e42RuL/1

regex101: build, test, and debug regex

Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET, Rust.

regex101
@d0nut bruh this is like hieroglyphics lol. what does this even do. i love some of the streams youve done btw

@strf0x

^ // At the start of a line
(?! // check if the following does **not** match (negative look-ahead)
( // create a capture group (group 1)
.{2,} // match 2 or more of any repeating character
) // end capture group (group 1)
\1+ // repeat matching capture group 1, one or more times
$ // match the end of the line
) // end negative look-ahead
.+ // match one or more characters

Technically it should be .{2,} at the end so we ensure we don't match a single element :)

Hope this helps! And thanks for watching my streams :)

@d0nut this is awesome man thanks. going to take me a minute to digest but appreciate it1

@strf0x My absolute pleasure! :D

I love helping people with regular expression questions. They're like a fun game to me at this point xD