Tier 1 · Sorcerermatch
The Prime Detector
You are given a string of 1s. Match it only when its length is a composite number — that is, not prime and not 1.
This is the most famous regular expression ever written, and it does something regex is not supposed to be able to do: arithmetic. The idea is to ask whether the run can be divided into two or more equal groups. If it can, the length is composite. If no division works, it is prime. Invert it with a negative lookahead and you have a prime detector in twelve characters.
Your pattern0 chars · par 11
//
Flags
Start typing — tests run as you go.0 of 7 visible tests passing
Test cases
1111must matchfour
111111must matchsix
111111111must matchnine
11must not matchtwo is prime
111must not matchthree is prime
11111must not matchfive is prime
1must not matchone is neither
+ 4 hidden tests, checked when you submit. They are what stops a pattern that only fits the examples above.