Editing Talk:1313: Regex Golf

Jump to: navigation, search
Ambox notice.png Please sign your posts with ~~~~

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 19: Line 19:
 
beyond others it will match all strings that contain a "b"? I can hardly believe that is not the case for any star trek subtitle... [[Special:Contributions/173.245.53.194|173.245.53.194]] 06:54, 6 January 2014 (UTC)
 
beyond others it will match all strings that contain a "b"? I can hardly believe that is not the case for any star trek subtitle... [[Special:Contributions/173.245.53.194|173.245.53.194]] 06:54, 6 January 2014 (UTC)
 
:This is the case for all Star Trek Subtitles. Wikipedia's list of movies had no b. It'll match anything containing a word ending in ''m'', any word beginning with ''n'' or ''t'' that is not the first word, or any word with a ''b''. No Trek movies match. Oddly, so far as I can figure out, the regex in the first panel is wrong, in that it doesn't match the second Star Wars movie at all. And before you tell me prequels don't count, the sole purpose of "m " is to match The Phanto''m ''Menace.[[Special:Contributions/199.27.128.138|199.27.128.138]] 07:10, 6 January 2014 (UTC)
 
:This is the case for all Star Trek Subtitles. Wikipedia's list of movies had no b. It'll match anything containing a word ending in ''m'', any word beginning with ''n'' or ''t'' that is not the first word, or any word with a ''b''. No Trek movies match. Oddly, so far as I can figure out, the regex in the first panel is wrong, in that it doesn't match the second Star Wars movie at all. And before you tell me prequels don't count, the sole purpose of "m " is to match The Phanto''m ''Menace.[[Special:Contributions/199.27.128.138|199.27.128.138]] 07:10, 6 January 2014 (UTC)
Attack of[ t]he Clones (to be read plainly, not as a regular expression). [[Special:Contributions/173.245.53.107|173.245.53.107]] 07:29, 6 January 2014 (UTC)
 
:Ah, I thought it was ''The Clone Wars''. [[Special:Contributions/199.27.128.138|199.27.128.138]] 15:36, 6 January 2014 (UTC)
 
So, if I add an "e" to the "tn" and delete the "|b" I'm a better golf player than her? [[Special:Contributions/108.162.212.194|108.162.212.194]] 08:23, 6 January 2014 (UTC)
 
:Or you could just move the "b" into the "tn" group. --11:08, 6 January 2014 (UTC)
 
 
I got a sneak preview of this comic at about 6:34 EST...at first it appeared to be random text in a irc message, but with this comic it now makes sense to me. [[User:Verticalbar|Verticalbar]] ([[User talk:Verticalbar|talk]]) 09:31, 6 January 2014 (UTC)
 
 
'''Regex golf''' (c.f. {{w|Perl golf}}) is a programming competition / is a pastime of finding regular expression that matches one set of strings while matching none of the other set.  See for example http://regex.alf.nu --[[User:JakubNarebski|JakubNarebski]] ([[User talk:JakubNarebski|talk]]) 11:03, 6 January 2014 (UTC)
 
 
The title text isn't exactly true... I haven't tried everything, but that regex doesn't match "gerald ford" at all. [[Special:Contributions/199.27.128.109|199.27.128.109]] 11:23, 6 January 2014 (UTC)
 
: Gerald Ford wasn't elected, he became President following Nixon's resignation.
 
[[Special:Contributions/173.245.52.209|173.245.52.209]] 12:12, 6 January 2014 (UTC)
 
 
Inspired by regex.alf.nu, a reader built a page where the objective is to make a regular expression to match all Star Wars and no Star Trek: http://zegnat.github.io/xkcd1313/. [[Special:Contributions/173.245.53.127|173.245.53.127]] 14:00, 6 January 2014 (UTC)
 
 
I added a list of all US elected presidents and the part of the title regex they match. I used a python script to generate it, with input from [http://http://en.wikipedia.org/wiki/List_of_United_States_presidential_candidates here], then I removed all presidents that do not match after finding they really weren't elected. There may still be superflous ones, that weren't elected but do match the regex, please check. [[Special:Contributions/173.245.49.64|173.245.49.64]] 14:29, 6 January 2014 (UTC)
 
 
Does anyone understand the final "No, I had those already"? Is it a reference to regexes in some way or could it be something like that there are infinite problems in life, even when not doing (Meta-)*-Regexes? --[[Special:Contributions/173.245.53.199|173.245.53.199]] 20:32, 6 January 2014 (UTC)
 
 
 
According to Peter Norvig (Director of research at google), one of the Regular Expression of Randall is wrong as demonstrated here : http://nbviewer.ipython.org/url/norvig.com/ipython/xkcd1313.ipynb [[User:Mbussonn|Mbussonn]] ([[User talk:Mbussonn|talk]]) 20:47, 6 January 2014 (UTC)
 
: It's happening. --[[Special:Contributions/173.245.53.153|173.245.53.153]] 11:39, 7 January 2014 (UTC)
 
 
"No one wins at [^ ]+ golf." [[Special:Contributions/141.101.98.209|141.101.98.209]] 09:50, 7 January 2014 (UTC)
 
: Gee, would that be "No one wins at \S+ golf."? [[User:IronyChef|IronyChef]] ([[User talk:IronyChef|talk]]) 23:57, 9 January 2014 (UTC)
 
 
Why does this say that it is Case Sensitive. As far as I can tell it would not work if that were true.[[Special:Contributions/108.162.219.59|108.162.219.59]] 02:28, 7 February 2014 (UTC)
 
 
"Note that if one included the animated film “Star Wars: The Clone Wars” it would be matched by “ [tn]”."
 
- I don't see how this is true, since the T is at the beginning of the subtitle.  If this matched, then surely so would all of the original series Star Trek films. {{unsigned ip|141.101.99.41}}
 
 
"I got infinite problems and a bitch ain,t one" 15:50, 29 August 2014 (UTC) {{unsigned ip|173.245.56.191}}
 
 
Looks like the algorithm is a bit outdated. It fails to match {{w|Star Wars: The Force Awakens|The Force Awakens}} but matches {{w|Star Trek Beyond|Beyond}}--[[Special:Contributions/108.162.212.51|108.162.212.51]] 17:57, 5 September 2015 (UTC)
 
 
For the 2016 election, the regex predicts that a Democrat (either) will beat Donald Trump, who will win the Republican primaries. {{unsigned ip|141.101.106.233}}
 
 
I like that linked article, even though I'm not really into programming. Just noticed Norvig misspells Randall's last name as Monroe instead of Munroe.
 
[[Special:Contributions/108.162.237.71|108.162.237.71]] 03:42, 15 March 2016 (UTC)
 
 
How would Trump work with this?
 
EDIT: Hillary works but Trump doesn't. [[Special:Contributions/162.158.75.73|162.158.75.73]] 00:23, 14 November 2016 (UTC)
 
 
 
The article says that the Presidents Regex is now impossible to update after Trump's win over Hillary. However, if Hillary were to win in a future election, it would work again as per the rule stated above the list, wouldn't it? --[[Special:Contributions/162.158.91.35|162.158.91.35]] 09:26, 3 April 2017 (UTC)
 
 
This isn't true either - there was already a presidential loser whose surname was Clinton (DeWitt Clinton, 1812). So presumably Hillary Clinton is likewise not considered in terms of regex eligibility. --[[Special:Contributions/172.68.132.59|172.68.132.59]] 23:05, 13 April 2017 (UTC)
 
 
For the Star Wars/Star Trek golf, including the new films, I've got /m | [tn]|ba|a[sw]/. Can anyone do better? {{unsigned|Misterblue28}}
 
:Including Star Wars films up to ''The Rise of Skywalker'', I get /ke|a.t.|n.*h/. --[[Special:Contributions/172.69.63.47|172.69.63.47]] 20:46, 20 May 2019 (UTC)
 
Does this work for Trump v Hillary? {{unsigned ip|162.158.154.103}}
 
: I was just wondering the same thing. Pretty sure it's now literally impossible, since you'd have to both match AND exclude "Clinton". [[Special:Contributions/162.158.75.88|162.158.75.88]] 13:15, 2 October 2018 (UTC)
 
 
== Regex golf with transcript ==
 
 
So I decided to play regex golf with the transcript (after learning regex) and it was kinda fun.
 
Here's my list of lines to match:
 
 
[Megan is sitting at a laptop. Cueball is standing behind her.]
 
 
Megan: /m | [tn]|b/ matches Star Wars subtitles but not Star Trek.
 
 
[A close-up of Megan at her laptop.]
 
 
Cueball (offscreen): Uh oh...
 
 
[Megan typing at her laptop.]
 
 
[Cueball facepalming.]
 
 
[Another closeup of Megan at her laptop.]
 
 
Cueball: Now you have infinite problems.
 
 
 
Here's my list of lines not to match:
 
 
Regex golf:
 
 
Megan: You try to match one group but not the other.
 
 
Cueball: Cool.
 
 
Meta-regex golf:
 
 
Megan: So I wrote a program that plays regex golf with arbitrary lists...
 
 
Meta-meta-regex golf:
 
 
Megan: ...But I lost my code, so I'm grepping for files that look like regex golf solvers.
 
 
...And beyond:
 
 
Megan: Really, this is all /(meta-)*regex golf/.
 
 
Megan: No, I had those already.
 
 
And here's my (very bad) regex.
 
\[|ms|h\.
 
(Hey, I learned yesterday)[[Special:Contributions/162.158.255.34|162.158.255.34]] 16:40, 17 October 2019 (UTC)
 
 
Wanted to drop this hairball from earlier:
 
    \/\/([^\n]|\\\n?)*$(?<!\\$)|\/\*(([^\/*]|\*(?!\/))*)\*\/
 
{{User:PoolloverNathan/Signature}} 17:29, 4 November 2022 (UTC)
 

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)

Templates used on this page: