Skip to main content
47 votes

Regex, Paper, Scissors, Lizard, Spock

PCRE, 15 14 bytes Rock: B Paper: \b$ Scissors: b|B. Lizard: ...
Anders Kaseorg's user avatar
46 votes

Regex, Paper, Scissors, Lizard, Spock

PCRE .NET, 35 32 bytes -3 bytes thanks to Martin Ender Rock: ([*?]$) Paper: [)$]$+ Scissors: ...
Business Cat's user avatar
  • 9,167
43 votes
Accepted

Regex Golf: Verify a Sudoku Solution

Ruby regex, 71 78 73 bytes ^(?!.*(?=(.))(.{9}+|(.(?!.{9}*$))+|(?>.(?!.{3}*$)|(.(?!.{27}*$)){7})+)\1) I don't really know Ruby but apparently it doesn't complain ...
jimmy23013's user avatar
40 votes

Regex, Paper, Scissors, Lizard, Spock

no fancy features, 35 30 bytes 5 bytes saved by Neil's idea which uses that ] needs no \. This works for example with the ...
Christian Sievers's user avatar
36 votes
Accepted

Distinguish English and Spanish with regular expressions

Any Language, 0.3677 (60.6064%, 1 byte) a No, I'm not joking. The single-character regular expression a successfully identifies ...
Silvio Mayolo's user avatar
33 votes

Regex Golf: Verify a Sudoku Solution

PCRE, 117 119 130 133 147 bytes ^(?!(.{27})*(...){0,2}(.{9})?.?.?(.).?.?(?=(?2)*$).{6,8}(?3)?\4.{0,17}(?1)*$|.*(.)(.{8}(?3)*|((?!(?3)*$)(|.(?7))))\5) Should also ...
feersum's user avatar
  • 31.4k
27 votes

Recognize most smaller primes with a regex

90 79 72 67 65 64 bytes ^(?!([258][0369]*[147]|[1475][258]|[147]{3}|[0369])+$)\d+[1379]$ Matches 2–3-digit numbers not divisible by 2, 3, or 5, with an added bit (...
m90's user avatar
  • 10.5k
26 votes

Regex, Paper, Scissors, Lizard, Spock

PCRE, 20 19 Rock W Paper ^\w Scissors ^\W Spock ...
TwiNight's user avatar
  • 4,800
25 votes
Accepted

Make a regex polyglot

87 bytes, 5 flavours, (87+10)/25 = 3.88 ^(((?=W)[[:word:]&&]art|Ho(?=a)\ar|Bre(?=ez)[]e]\z|E(?=dg)[[d]]g)y|(?=Da)[D-[E]]apper)$ I've gone with the easy ...
Sp3000's user avatar
  • 61.9k
22 votes

Complement a POSIX Extended Regular Expression

JavaScript, 1563 bytes ...
tjjfvi's user avatar
  • 7,350
21 votes

Regex, Paper, Scissors, Lizard, Spock

20 bytes R = 'R|VP' L = 'L|RS' V = 'V|LP' S = 'S|RV' P = 'P|LS'
emulbreh's user avatar
  • 311
20 votes
Accepted

Check if simple regex matches string

Haskell, 203 bytes Nobody had done this by implementing a small regex engine yet, and I felt like it had to be done. This obviously won't win. but I'm hoping it will inspire someone to write an even ...
ankh-morpork's user avatar
  • 1,485
18 votes

HexaRegex: A Tribute to Martin Ender

Retina, 744 bytes Sorry folks, no Hexagony this time... Byte count assumes ISO 8859-1 encoding. ...
Martin Ender's user avatar
17 votes
Accepted

A regex to satisfy the grammar police (there vs. their vs they're)

There isn't a lot of room for optimisation here. This seems to be optimal: the(y're|re|ir) The only alternative I can think of avoids the duplication of ...
Martin Ender's user avatar
16 votes

Match the Stack Exchange URLs

337 336 333 327 bytes ...
orlp's user avatar
  • 39.1k
16 votes

A regex to match three consecutive integers iff the third integer is the sum of the first two

Perl/PCRE: 2,685 bytes ^(?!(?!0*+(?=(\d*?)((?:(?=\d+ 0*+(\d*?)(\d(?(4)\4)) 0*(\d*?)(\d\6?+)$)\d)+) )(?=(?(?!\1(?:(?=\d+ 0*\3((\7?+)\d))(?=\d(\d* 0*\3\8))(?=0\9[9]|1\9[8]|2\9[7]|3\9[6]|4\9[5]|5\9[4]|6\...
jaytea's user avatar
  • 507
15 votes

Regex Golf: Verify a Sudoku Solution

.NET regex, 8339 bytes Yes, I know my solution is very naive, since Martin told me he did it in like 130 bytes. In fact, the URL to try it online is so long that I couldn't find a URL shortener that ...
mbomb007's user avatar
  • 23.4k
14 votes

Regex Golf: Verify a Sudoku Solution

.NET regex, 121 bytes ^(?!(.{27})*(.{9})?(...){0,2}.?.?(.).?.?(?=(...)*$)(.{9})?.{6,8}\4.{0,17}(.{27})*$|.*(?=(.))((.{9})+|(.(?!(.{9})*$))+)\8) Explanation: <...
Neil's user avatar
  • 172k
14 votes
Accepted

Match the permutations!

JavaScript, 64 57 bytes 4 bytes removed thanks to Martin Ender. ^(?!.*([^])(.*\1){3}]?)[$$[-^?!!.'''-*11{33}5577\\-]{57}$ Try it here. Explanations (outdated) <...
jimmy23013's user avatar
13 votes

HexaRegex: A Tribute to Martin Ender

Python 3, 990 943 770 709 bytes First answer, yay! EDIT: Golfed adjacency list making. I now use a slightly different formula EDIT 2: Removed unnecessary fluff, golfed a lot more. EDIT 3: ...
Blue's user avatar
  • 2,036
13 votes

Complement of a Regex

Dyalog APL, 166 bytes ...
user41805's user avatar
  • 13.1k
12 votes

Regex: Match an egalitarian series

.NET flavour, 48 bytes ^(.)\1*((?<=(\5())*(.))(.)(?<-4>\6)*(?!\4|\6))+$ Try it online! (using Retina) Well, turns out that not negating the logic is ...
Martin Ender's user avatar
11 votes

Match strings whose length is a fourth power

.NET, 39 37 bytes ^(?=((?>^((?<-1>x)+|x)|\1\2\2))*$){2} Try it online! Not only does this outgolf primo's amazing answer, but it runs at very close to ...
Deadcode's user avatar
  • 11.6k
10 votes

Match strings whose length is a fourth power

ECMAScript, 41 bytes ^((?=(x(x*)|)(?=(\2*)\3+$)(\2*$\4))\5){2} Try it online! - ECMAScript (SpiderMonkey) Try it online! - ECMAScript (Node.js - faster) Try it ...
Deadcode's user avatar
  • 11.6k
10 votes

Enumerate all matches of a regex

Python, 214 bytes ...
Bubbler's user avatar
  • 77k
9 votes

Shortest simple regex matching a binary word

JavaScript (ES6), 488 341 bytes ...
Neil's user avatar
  • 172k
9 votes

Is case sensitivity important? Part II: reality check

Haskell, 41 bytes d n=sum[26^a*10^k|a<-[1..n],k<-[0..n-a]] Runtime: O(k*n²), where k depends on the size of the resulting numbers. Results ...
Zeta's user avatar
  • 701
9 votes

Cops: Make a regex - Make a snake

05AB1E, Cracked by mbomb007 Hopefully fun to crack and not too obvious. Regex (PCRE): ^\w*[+\-*\/%]*\w*.{0,2}$ Output n=4: ...
Emigna's user avatar
  • 53k
9 votes

Robbers: Crack the regex - Make a snake

05AB1E, Emigna This was my first time using 05AB1E. Got it with a little bit of help. That was fun. :) UXFXLNX*+N2BSR1k_iR}ˆ Try it online Explanation: ...
mbomb007's user avatar
  • 23.4k

Only top scored, non community-wiki answers of a minimum length are eligible