1:37 AM
Divide by the largest prime factor: `^(x+?)(?=\1+\$)(?!(\1+)(\1\2)+\$)`

1:50 AM
Of course, only useful if you don't need to capture the largest prime factor. It's in the same vein as the implicit division-by-odd-number done in `(?!(x*)(\1\1)+\$)`, which blew my mind. I went for 5 years thinking there were exactly two 17 character power-of-two regexes, and there were actually three.

5 hours later…
7:20 AM
@Grimy Regexes I was able to shorten using your division golf trick: Is this a consecutive-prime/constant-exponent number?, Is it a Proth number?, OEIS A033286 (prime × index),

Ooh
Some of these I hadn’t seen before
Doesn’t the largest prime factor trick get some use as well?

Additionally, the OEIS A033286 one was able to benefit from your shorter largest-prime-factor

7:57 AM
Another equal-length (30 char) form for "divide by the largest prime factor": `(x+?)(?=(\1+?)(\1\2)*\$)(?=\2\$)`
The molecular lookahead version is also the same length: `(?*(x+?)\1+\$)(?!(\1\1+)\2+\$)\1`

7 hours later…
3:03 PM
40 on Proth

2 hours later…
4:45 PM
@Grimy How?

4:58 PM
Oh, I might see
It will be harder to comment
Nope, I don't see
Oh I think I do see
No, I don't see.

2 hours later…
6:47 PM
Interesting back and forth x)
0

Regex (ECMAScript), 40 bytes ^x(?=((xx)+?)(\1\1)*\$)(?!(\1x(xx)*)\4*\$) Try it online! Commented version: ^x # Subtract 1 from the input N (?=((xx)+?)(\1\1)*\$) # Assert N is even. Capture \1 = biggest power of 2 that divides N (?!(\1x(xx)*)\4*\$) # Assert no odd number > \1 ...

2 hours later…
9:15 PM
@Grimy Did you intentionally leave a bit in your regex unoptimized so I could have the pleasure of finding it? :)

I didn’t
Oooh \2 as a shortcut for (xx)
Great find

:D
@Grimy You didn't update the comments. I'd put in the bit that \2 = 2