Solved

Regex golf anyone?

Posted on 2014-04-29
10
518 Views
Last Modified: 2014-08-27
Ok, so there's a website for playing "Regex golf" here: http://regex.alf.nu/

Basically, you get given some things to match and some things to not match and you have to write a single regular expression (in as few chars as possible) to do it.

Hopefully we'll see some of other top guys in the Regular Expressions Topic Area too... @ozo, @kaufmed, @DanCraciun, @ddrudik

Let me know your score :-)

This is really more like a lounge question so I've kept points to 50...
0
Comment
Question by:Terry Woods
10 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40031277
Cool, did not know that site!

Got stuck at Balance. Got 3 mismatches for 402 points (total 2961). Will try again tonight.

BTW, this is in normal mode. Did not touch hard mode yet. I guess Ozo will start directly in hard mode, to not get bored :)
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 40031286
Trust me, even the normal mode is tough!
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 40033036
Finished the first run. 3489 points. Probably can improve, but rushed to finish.

LE: A bit of tinkering. 3511 points. Enough for tonight.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 35

Assisted Solution

by:mccarl
mccarl earned 12 total points
ID: 40033740
I got 3841 but a couple of the regex aren't "in the spirit" of what the puzzle setter was trying to aim for, eg. Glob, Triple, Long Count wouldn't work if a different set of examples were picked. Triples is especially annoying because I know exactly what I want to do but just not how to get that into a regex! :)
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 40033745
Great score, @mccarl! So far I've managed 3682, and I'm sure that more than a couple of my answers aren't a particularly general pattern either.
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 25 total points
ID: 40035550
Finally got balance. Actually, it was easier once I understood I had to close all tags :)

New score 3756.
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 40035725
I'm sitting on 407 points for "balance" though I still have an incorrect match. What points do you have for that one, Dan?

I would expect to have substantial room for improvement on "Powers" (57 points) and "Powers 2" (37 points).

No time to go back to it today though... :-(
0
 
LVL 34

Assisted Solution

by:Dan Craciun
Dan Craciun earned 25 total points
ID: 40035751
452 at "balance". Though I did somewhat cheat on it to get all the matches. Could not get a general regex so used an alternation for 4 of the matches.
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 13 total points
ID: 40042033
I just saw this thread today. I'll play around with it more tonight. 1500 so far, but I'm only half done, and a couple were just brute force.
0
 
LVL 35

Author Comment

by:Terry Woods
ID: 40074196
Will have to accept a solution to this question soon, or my name will be mud... any updates on score? :-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
regex replace up to char or end of line 5 66
Regex Balancing Group 30 89
regex code to filter this ip's? 2 37
Split string on commas but not when enclosed in parentheses 7 58
As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question