Live data from Hacker News

Regex Golf

regex.alf.nu

31–40 of 189 posts

Re: Regex Golf

#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*$

Re: Regex Golf

#33
post #28
post #19

Earlier quoted context omitted.

Anchors (208): k$ Ranges (202): ^[a-f]+$ Backrefs (199): (\w{3}).*\1

Backrefs (201): (...).*\1

Wait, so what's with the 'point system' here? Why's shdon answer for backrefs 199 and yours 201? (and while you're at it, could you briefly explain (...).*\1 for the regex newbies?)

Re: Regex Golf

#34

am I being a bit slow? Why doesn't [^g-z] work on 'ranges'?

Because for example "beam" matches [^g-z]. That is, it has a letter somewhere that is not between g and z (namely e and a). I came up with ^[a-f]+$ but I'm guessing it could be shorter :)

Edit: ah, every word in left column has 4 a-f letters. So [a-f]{4} is a shorter match.

Re: Regex Golf

#35
post #33
post #28

Earlier quoted context omitted.

Backrefs (201): (...).*\1

Wait, so what's with the 'point system' here? Why's shdon answer for backrefs 199 and yours 201? (and while you're at it, could you briefly explain (...).*\1 for the regex newbies?)

"You are deducted one point per character you use, and ten if you match something you shouldn't."

Re: Regex Golf

#39
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*$

Four: 199

    (.)(.\1){3}
Order: 168

    ^a*b*c*d*e*f*g*h*i*l*m*n*o*p*r*s*t*w*y*z*$
(You just didn't remove unused letters.)
Post reply on HN