Live data from Hacker News

Regex Golf

regex.alf.nu

171–180 of 189 posts

Re: Regex Golf

#172
post #71

Earlier quoted context omitted.

Mine is a bit shorter, though a bit more "meh" as well. ^x{32}$|^(x{2}){1,8}$|^(x{64})+$|^x$

improved, gives 80 ^(x|(xx){1,9}|x{32}|(x{64})+)$

I tried to get rid of those redundant ^ and $ but it somehow didn't work. I probably forgot to put it all inside one group.

Re: Regex Golf

#174
post #43
post #31

I got Four for 196 with (.).*\1.\1.*\1 and Order for 156 with ^a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$

Order for 198: ^[^o].....?$ Probably not what was wanted, but it works (or maybe it was to trick people onto a false path)

This right here is why test cases are always blackboxed...

Re: Regex Golf

#175
post #4

Fun learning tool for regex.

Practise, maybe. Learning, probably not so much. Certainly fun, though, if you can cope with them!

Learning, kinda. I've often been motivated to learn something after being given a problem that can only be solved (or be solved much more easily) using it. Every other Excel trick I know is a result of that.

Re: Regex Golf

#176
post #43
post #31

I got Four for 196 with (.).*\1.\1.*\1 and Order for 156 with ^a*b*c*d*e*f*g*h*i*j*k*l*m*n*o*p*q*r*s*t*u*v*w*x*y*z*$

Order for 198: ^[^o].....?$ Probably not what was wanted, but it works (or maybe it was to trick people onto a false path)

or ^[^o].{1,5}$

198 points

Re: Regex Golf

#177
post #90

Does anybody know how to do math with regex? (triples) And conditionals don't seem to work?

From: http://quaxio.com/triple/ ^([0369]|[258][0369]*[147]|[147]([0369]|[147][0369]*[258])*[258]|[258][0369]*[258]([0369]|[147][0369]*[258])*[258]|[147]([0369]|[147][0369]*[258])*[147][0369]*[147]|[258][0369]*[258]([0369]|[147][0369]*[258])*[147][0369]*[147])*$

The idea is as thus:

Remember division rules? If the sum of digits is divisible by 3, then the number is divisible by 3

So, if you have 0, 3, 6, 9, it's as you can remove them, the value won't change

Remaining are the 2, 3, etc digit numbers divisible by 3

Post reply on HN