Live data from Hacker News

Regex Golf

regex.alf.nu

41–50 of 189 posts

Re: Regex Golf

#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)

Re: Regex Golf

#44

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.

[deleted]

Re: Regex Golf

#45

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.

ah you're right :) I was being slow, what I thought I wrote was 'words consisting only of letters that arent g-z'

Re: Regex Golf

#48
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?)

Regex explained:

    (...) # Match exactly 3 (the dots) characters and save them as a group (the parenthesis)
    .* # Match any character (the dot) 0 or more times (the asterisk)
    \1 # Reuse the first group

Re: Regex Golf

#50
post #14

Shouldn't the objective be to get the lowest score if it's called "golf?"

The goal in code golf is lower character count, not lower score - which is also the case here.

Therefore, the score it provides should be a running tally of how many characters you've used to make it match the scoring system of golf; which is the lowest number of strokes wins.

The scoring system for this is incremental which is the opposite of golf.

A proper scoring system with this would provide a character limit (par) for each section and the goal would be to write a shorter regex formula to complete the task. Final score would be how many characters under or over the total character limits (course par) you scored.

Seems this is more like Regex Darts or something like that.

But it's fun nonetheless.

Post reply on HN