Skip to content

Instantly share code, notes, and snippets.

@shuding
Created November 23, 2014 00:13
Show Gist options
  • Save shuding/056521c77be10f629df4 to your computer and use it in GitHub Desktop.
Save shuding/056521c77be10f629df4 to your computer and use it in GitHub Desktop.
Solutions to Regex Golf (https://regex.alf.nu/)

Regex Golf.

Normal levels

做了一遍,然后搜集了目前的最优答案:

  1. Warmup (207): foo
  2. Anchors (208): k$
  3. Ranges (202): ^[a-f]+$
  4. Backrefs (201): (...).*\1
  5. Abba (195): ^(?!.*(.)\1)|ef
  6. A man, a plan (177): ^(.)[^p].*\1$
  7. Prime (286): ^(?!(xx+)\1+$)
  8. Four (199): (.)(.\1){3}
  9. Order (199): ^.{5}[^e]?$
  10. Triples (596): 00($|3|6|9|12|15)|4.2|.1.+4|55|.17
  11. Glob (397): [bncrw][bporn]|^p|c$|ta
  12. Balance (447): ^(<(<(<(<(<(...)*>)*>)*>)*>)*>)*$
  13. Powers (93): ^(?!(x(xx)+)\1*$)
  14. Long count (256): ((.+)0\2+1){8}
  15. Alphabetical (317): .r.{32}r|a.{10}te|n.n..
  16. Powers 2 (88): ^(.|(...)+)$

这东西真是有趣呀 ^ ^

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