« first day (72 days earlier)      last day (1255 days later) » 

10:03 AM
28: ^(?!((xx+)\2+)\1+$)(xx+)\3+$
 
Here's 27, but I doubt it's the shortest
^(?=((xx+?)(\2*))\1+$)x+$\3
 
10:40 AM
^(?=((x(x*))\2+)\1+$)x+$\3
 
^((x(x*))\2+)\1+$\3
 
That matches 8
 
whoops
well x+$\3 can be \3^, that's still two bytes saved
 
Nice
 
oh and then the first ^ can be dropped
(?=((x(x*))\2+)\1+$)\3^
this also gives a nice way to match primes: (?=(x(x*))\1+$)\2^
two bytes longer than the shortest known prime regex, but uses (?=) instead of (?!), which might save bytes when used inside a bigger regex
 
 
6 hours later…
4:55 PM
@Grimy Can you get this shorter? codegolf.stackexchange.com/questions/129173/…
 
5:15 PM
sure
-5 bytes and much faster: ^(?!(x+)(?!(x(xx)+)\2+$)x*(?=\1$)(?!(x(xx)+)\4+$)|(xx)+$)
still looks easily improvable
another -11 bytes: ^(?!(x+)((?!(x(xx)+)\3+$)x*(?=\1$)){2}|(xx)+$)
@H.PWiz
this incorrectly matches 0, but the input is specified as positive, so i think that’s fine
 
Oh, for goodness sake. I new what (?!(x(xx)+)\1+$) did, because I used, but I didn't put the pieces together. Nice work.
Yes, mine was false positive for 0 aswell
 
oh wait the |(xx)+$ part isn’t needed
down to 39 bytes
 
Are you sure that your's matches numbers of the form 2^n+1, like 262145?
 
is that the first one of this form?
 
I'm not sure.
 
5:22 PM
my regex is taking forever to run on it, a smaller example would be convenient
 
I got it from, the text that Deadcode gave, I assume he provided the smallest one
 
the fix is only one byte anyway
change the first (x+) to (xx+)
 
Then, it matches 2 and 3
 
ugh
 
I suppose mine might not need the (...)? bit, so I'm on 56 bytes
 
5:28 PM
well ^(?!(xx+)((?!(x(xx)+)\3+$)x*(?=\1$)){2}|xxx?$) is 46
but surely there’s a better way to handle 2 and 3
 
Also, does yours rely on Goldbach's conjecture? (or at least a weaker form of it)
 
yep
removing the |(xx)+$ bit requires Golbach
without Golbach and with correct behavior on 2^n + 1 we have 52: ^(?!(xx+)((?!(x(xx)+)\3+$)x*(?=\1$)){2}|(xx)+$|xxx$)
certainly improvable
 
You could move (xx)+ to the start, and replace the later (xx) by \1
 
doesn’t work in a (?!)
or does it?
 
Oh yeah, won't work with the |
^x(?!(x+)((?!(x(xx)+)\3+$)x*(?=\1x$)){2}|xx$)(xx)*$
 
6:24 PM
Or better yet: ^(?!(xx+)((?!(x(xx)+)\3+$)x*(?=\1$)){2}?\1$|xxx?$)
 
6:44 PM
pretty sure {2}? only works in RME, not in actual ECMA regexes
 
 
4 hours later…
10:49 PM
I've managed to golf mine down to: ^(?!((xx?)x*)((?!(x\2+)\4+$)x*(?!(x\2(xx)*)\5+$))?\1$)
Which is only 3 bytes longer than the other one currently
 
11:11 PM
Merging that with Grimy's however, gives 48 bytes: ^(?!((xx?)x*)(((?!(x\2+)\5+$)x*(?=\1$)){2})?\1$)
 
without Goldbach?
 
Yeah, it matches even numbers with (x+)\1$
 
11:34 PM
Also, it appears that {2}? works in regular ECMAScript, so -3 bytes
nvm, that is wrong
 
11:49 PM
I suspect that the first x* can be replaced by +, but that is very slow
 

« first day (72 days earlier)      last day (1255 days later) »