Skip to content

Instantly share code, notes, and snippets.

@jpsim
Last active January 13, 2022 20:47
Show Gist options
  • Star 78 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save jpsim/8057500 to your computer and use it in GitHub Desktop.
Save jpsim/8057500 to your computer and use it in GitHub Desktop.
  1. Plain Strings (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]*$
  4. Backrefs (201): (...).*\1
  5. Abba (169): ^(.(?!(ll|ss|mm|rr|tt|ff|cc|bb)))*$|^n|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(..+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (198): ^[^o].....?$
  10. Triples (507): (^39|^44)|(^([0369]|([147][0369]*[258])|(([258]|[147][0369]*[147])([0369]*|[258][0369]*[147])([147]|[258][0369]*[258])))*$)
  11. Glob (364): ^((\*(er|f|i|p|t|v))|(b|c(h|o|r)|do|l|mi|p(a|r|u)|re|w))
  12. Balance (286): ^(<(<(<(<(<(<<>>)*>)*>)*>)*>)*>)*$
  13. Powers (56): ^((((((((((x)\10?)\9?)\8?)\7?)\6?)\5?)\4?)\3?)\2?)\1?$

Total Score: 3060

@leiserfg
Copy link

Power 2:^(?!((xxx)+x|xx)\1*$)

@vinodselvin
Copy link

It never ends: u\b

@Davidebyzero
Copy link

I've updated Best known Regex Golf solutions. The current Classic level set is fully covered. It's now in table format, including full credits and date-time stamps, a history of gradual improvements for most of the levels, and some extra bonus information.

I have intentionally not updated the Teukon level set solutions compilation, nor posted one for Holiday, as with the release of functioning high score lists in the newly brought back Regex Golf site, to do so would further taint the high scores with people who simply Google it and copy the solutions. This is not an ideal situation by any means, as I'd really like for everyone to be able to benefit from this knowledge if they so desire, but given the way the on-site high score lists currently function, I see no alternative. Having date-time stamps in the on-site high score lists would be a good start towards fixing this problem.

@moon-home
Copy link

Abba (193): ^(?!.*(.)(.)\2\1)

Hi @jonathanmorley, can you enlighten me why (?!(.)(.)\2\1) matches abba? isn't it matching any string that does not have a 4 characters palindrome?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment