Editing Talk:1638: Backslashes

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 10: Line 10:
 
:Did that before seeing you comment, so yes I agree. --[[User:Kynde|Kynde]] ([[User talk:Kynde|talk]]) 09:47, 3 February 2016 (UTC)
 
:Did that before seeing you comment, so yes I agree. --[[User:Kynde|Kynde]] ([[User talk:Kynde|talk]]) 09:47, 3 February 2016 (UTC)
 
::But Davidy did not so the category has been deleted again. I have just cleaned up after my mess ;-) so there are no left over links to the dead category... --[[User:Kynde|Kynde]] ([[User talk:Kynde|talk]]) 22:27, 8 February 2016 (UTC)
 
::But Davidy did not so the category has been deleted again. I have just cleaned up after my mess ;-) so there are no left over links to the dead category... --[[User:Kynde|Kynde]] ([[User talk:Kynde|talk]]) 22:27, 8 February 2016 (UTC)
:::I noticed theres no character for Ba'al the soul eater on the character page. Is it just me or does someone else think that Ba'al should have a spot given that he(she??they??it??) has been in more comics than a lot of the minor characters? Just a thought. --[[User:Apollo11|Apollo11]] ([[User talk:Apollo11|talk]]) 10:42, 11 March 2024 (CST)
 
  
 
The last entry may also be an oblique reference to the infinitely-expandable recursive acronym "GOD = GOD Over Djinn" mentioned in Richard Hofstadter's Gödel, Escher, Bach.[[User:Taibhse|Taibhse]] ([[User talk:Taibhse|talk]]) 16:42, 3 February 2016 (UTC)
 
The last entry may also be an oblique reference to the infinitely-expandable recursive acronym "GOD = GOD Over Djinn" mentioned in Richard Hofstadter's Gödel, Escher, Bach.[[User:Taibhse|Taibhse]] ([[User talk:Taibhse|talk]]) 16:42, 3 February 2016 (UTC)
  
 
;I don't think the regex is invalid
 
;I don't think the regex is invalid
''Note: The regex changed after initial publication. See '''Changed Regex''' below''
 
  
 
According to <tt>man grep</tt> you need to specify the <tt>-E</tt> option to use extended regex; without it unescaped parentheses are not interpreted, so they don't need to match.
 
According to <tt>man grep</tt> you need to specify the <tt>-E</tt> option to use extended regex; without it unescaped parentheses are not interpreted, so they don't need to match.
Line 57: Line 55:
 
::::: Since no-one else seemed to want to, I just restructured that paragraph to make it more clear that if anything Harry Potter was inspired by the older examples, not the other way around. Expanded the LOTR reference and added DnD. If anything Randall is likely to be referencing either the Lovecraft references, or the concept of Elder in general. [[Special:Contributions/141.101.64.173|141.101.64.173]] 11:50, 4 February 2016 (UTC)
 
::::: Since no-one else seemed to want to, I just restructured that paragraph to make it more clear that if anything Harry Potter was inspired by the older examples, not the other way around. Expanded the LOTR reference and added DnD. If anything Randall is likely to be referencing either the Lovecraft references, or the concept of Elder in general. [[Special:Contributions/141.101.64.173|141.101.64.173]] 11:50, 4 February 2016 (UTC)
  
Attempting to add to the discussion: This regex is not necessarily invalid or incomprehensible.  (''Note: The regex changed after initial publication. See '''Changed Regex''' below.'') It looks like he was looking for a line with a regular expression or definitely some code.  You just have to work your way through the backslashes.  Although it might be invalid depending on the precise rules.  He has some unescaped closing brackets and closing parenthesis.  If these have to always be escaped then the regex is invalid.  If however you  don't have to escape a closing bracket with no opening bracket, then things are fine.  I'm not familiar enough with grep's regex parser to know how it handles that edge case.  Presuming those unescaped paren and brackets are fine, his regex searches for:
+
Attempting to add to the discussion: This regex is not necessarily invalid or incomprehensible.  It looks like he was looking for a line with a regular expression or definitely some code.  You just have to work your way through the backslashes.  Although it might be invalid depending on the precise rules.  He has some unescaped closing brackets and closing parenthesis.  If these have to always be escaped then the regex is invalid.  If however you  don't have to escape a closing bracket with no opening bracket, then things are fine.  I'm not familiar enough with grep's regex parser to know how it handles that edge case.  Presuming those unescaped paren and brackets are fine, his regex searches for:
  
 
1. A backslash
 
1. A backslash
Line 112: Line 110:
 
(Perhaps just something like the penultimate paragraph, if we're not entirely mistaken?) [[Special:Contributions/162.158.152.89|162.158.152.89]] 14:14, 3 February 2016 (UTC)
 
(Perhaps just something like the penultimate paragraph, if we're not entirely mistaken?) [[Special:Contributions/162.158.152.89|162.158.152.89]] 14:14, 3 February 2016 (UTC)
  
The regex is supposed to be looking for (''Note: The regex changed after initial publication. See '''Changed Regex''' below.''):
+
The regex is supposed to be looking for:
 
  \\\      backslash
 
  \\\      backslash
 
  [[(]    [ or (
 
  [[(]    [ or (
Line 131: Line 129:
  
  
The regex relies on several special cases (*surprise*). (''Note: The regex changed after initial publication. See '''Changed Regex''' below.'')
+
The regex relies on several special cases (*surprise*).
 
First: bash double-quote expansion (see [https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#Double-Quotes]). Perhaps non-intuitively, \\\ followed by a character that \ doesn't escape is an escaped backslash followed by a literal backslash, effectively the same as \\\\ followed by that same non-escaped character.  After bash double-quote expansion, this results in:
 
First: bash double-quote expansion (see [https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html#Double-Quotes]). Perhaps non-intuitively, \\\ followed by a character that \ doesn't escape is an escaped backslash followed by a literal backslash, effectively the same as \\\\ followed by that same non-escaped character.  After bash double-quote expansion, this results in:
  
Line 171: Line 169:
  
 
;Example of a match
 
;Example of a match
''Note: The regex changed after initial publication. See '''Changed Regex''' below''
 
  
 
First, the shell will do some escaping substitution. So, in order to easily read it, let's see what grep really receives:
 
First, the shell will do some escaping substitution. So, in order to easily read it, let's see what grep really receives:
Line 202: Line 199:
 
:You're making the same mistake Randall did: while many (most?) regex dialects use \ as escape inside a character class, this is not true for grep's default syntax. I've expanded that interpretation in my comment below, however the analysis by 108.162.228.167 is a correct explanation of how this expression is ''actually'' interpreted by grep. --[[Special:Contributions/141.101.75.185|141.101.75.185]] 15:42, 4 February 2016 (UTC)
 
:You're making the same mistake Randall did: while many (most?) regex dialects use \ as escape inside a character class, this is not true for grep's default syntax. I've expanded that interpretation in my comment below, however the analysis by 108.162.228.167 is a correct explanation of how this expression is ''actually'' interpreted by grep. --[[Special:Contributions/141.101.75.185|141.101.75.185]] 15:42, 4 February 2016 (UTC)
  
Your analysis is thorough and correct, however it is unlikely this is what the regex was intended to accomplish. (''Note: The regex changed after initial publication. See '''Changed Regex''' below.'') More likely, Randall is more accustomed to other regex dialects such as Perl(-compatible) regex where a backslash ''does'' work to escape special characters inside a character class.  Under that assumption the regex (with some whitespace inserted for readability) would break up as:
+
Your analysis is thorough and correct, however it is unlikely this is what the regex was intended to accomplish. More likely, Randall is more accustomed to other regex dialects such as Perl(-compatible) regex where a backslash ''does'' work to escape special characters inside a character class.  Under that assumption the regex (with some whitespace inserted for readability) would break up as:
 
* <code>\\ [[(]</code> an escaped opening bracket or paren
 
* <code>\\ [[(]</code> an escaped opening bracket or paren
 
* <code>.*</code> anything
 
* <code>.*</code> anything
Line 237: Line 234:
 
This makes hardly more sense than the original command.
 
This makes hardly more sense than the original command.
 
--[[User:Markus|Markus]] ([[User talk:Markus|talk]]) 17:38, 9 February 2016 (UTC)
 
--[[User:Markus|Markus]] ([[User talk:Markus|talk]]) 17:38, 9 February 2016 (UTC)
:Randal may have been sincere about finding it in his history and wondering if it worked. I think he probably meant
 
cat out.txt | grep -o "[[(].*[])][^])]*$"
 
 
:which breaks down as:
 
[[(]  either a '[' or a '('
 
.*    an unbounded and possibly empty sequence of arbitrary characters
 
[])]  either a ']' or a ')'
 
[^])]*  any number of any characters except for a ')' or ']'
 
$    anchored at end of line
 
 
:This matches any line that has a '[' or '(' followed by a ')' or ']', matching from the first '[' or '(' to the end of the line. The final part of the regex, '[^])]*$', is not really necessary here, but it is a common pattern to follow a character pattern with an opposite character pattern to be sure the first character pattern matches the last instance of a repeating character, so he might have added it out of habit, which would explain also why he got it wrong (since he just followed '[blah]' with '[^blah]' which in this special case doesn't work because 'blah' has a special character in it: ']').
 
:[[User:Jgro|Concerned Netizen]] ([[User talk:Jgro|talk]]) 02:23, 25 April 2017 (UTC)
 
 
----
 
----
 
Funny enough, I'm literally looking at some other dev's code right now that actually implements an eight backslash regex sequence, with just the comment "backslash". I'm still scratching my head over what they were trying to accomplish or even communicate with this. [[User:Domino|Domino]] ([[User talk:Domino|talk]]) 21:45, 16 August 2016 (UTC)domino
 
Funny enough, I'm literally looking at some other dev's code right now that actually implements an eight backslash regex sequence, with just the comment "backslash". I'm still scratching my head over what they were trying to accomplish or even communicate with this. [[User:Domino|Domino]] ([[User talk:Domino|talk]]) 21:45, 16 August 2016 (UTC)domino
 
----
 
----
I believe the regex is a reference to xkcd 1313 (Regex Golf)
 
[[Special:Contributions/108.162.221.90|108.162.221.90]] 16:08, 26 August 2016 (UTC)
 
----
 
I had to use a backslash that escaped the screen today. I have a Discord bot written with Node.js, and my "friends" demanded I add a shruggie output [despite Discord having that already]. So, I now have a string that looks like <code>'¯\\\\\\_(ツ)\_/¯'</code>.{{unsigned|Papayaman1000}}
 
----
 
Regarding the change to the title text (with all backslashes being removed) it appears that this may not be a deliberate edit, as other comics (e.g. 1277) have also had all backslashes disappear from the title text. It appears that one of the tools Randall is using may be 'solving' accidentally escaped characters by doing a sed 's/\\//g' [[User:Sqek|Sqek]] ([[User talk:Sqek|talk]]) 13:18, 14 December 2017 (UTC)
 
 
<code>sed -r "s/^(.*)$/^\1$/" wordlist.txt</code> What was I cooking... There are also cursed grep commands for wordle such as <code>grep -iwE '[qwiafghjkzxvbn]{5}' wordlist.txt | grep -i '.[^ia][^n][^ai][^n]' | grep -i [ain] </code> [[User:Wilh3lm|Wilh3lm]] ([[User talk:Wilh3lm|talk]]) 14:19, 16 April 2024 (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: