Regex Golf 练习记录

正则表达式的练习网站:https://alf.nu/RegexGolf

共17道题:只能说从第10题开始就很变态了,就是看看答案好了

1.Warmup: foo
2.Anchors: k$ 或 ick$
3.It never ends: fub
4.Ranges: ^[a-f]*$ 或 [a-f]{4}
5.Backrefs:(...).*1
6.Abba: ^(?!.*(.)(.)21)
7.A man, a plan: ^(.)(.).*21$ 或 ^(.)[^p].*1$ 或 (.)(.).?21.?$
8.Prime: ^(?!(xx+?)1+$) 或  ^(?!(..+)1+$)
9.Four: (.)(.1){3} 
10.Order: ^.{5}[^e]?$
11.Triples: 00($|3|6|9|12|15)|4.2|.1.+4|55|.17
12.Glob: ai|c$|^p|[bcnrw][bnopr]
13.Balance: ^(<(<(<(<(<(<<>>)*>)*>)*>)*>)*>)*$
14.Powers: ^(?!(.(..)+)1*$)
15.Long count: ^((.+)0 2+1 ?)*$
16.Alphabetical: .r.{32}r|a.{10}te|n.n..
17.Powers2: ^((x+)2(?=2$))*x$
原文地址:https://www.cnblogs.com/etangyushan/p/10990387.html