<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://www.explainxkcd.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=00pebuis</id>
		<title>explain xkcd - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://www.explainxkcd.com/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=00pebuis"/>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php/Special:Contributions/00pebuis"/>
		<updated>2026-04-13T15:11:13Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://www.explainxkcd.com/wiki/index.php?title=1638:_Backslashes&amp;diff=112849</id>
		<title>1638: Backslashes</title>
		<link rel="alternate" type="text/html" href="https://www.explainxkcd.com/wiki/index.php?title=1638:_Backslashes&amp;diff=112849"/>
				<updated>2016-02-19T15:27:58Z</updated>
		
		<summary type="html">&lt;p&gt;00pebuis: /* Explanation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{comic&lt;br /&gt;
| number    = 1638&lt;br /&gt;
| date      = February 3, 2016&lt;br /&gt;
| title     = Backslashes&lt;br /&gt;
| image     = backslashes.png&lt;br /&gt;
| titletext = I searched my .bash_history for the line with the highest ratio of special characters to regular alphanumeric characters, and the winner was: cat out.txt &amp;amp;#124; grep -o &amp;quot;\\\[[(].*\\\[\])][^)\]]*$&amp;quot; ... I have no memory of this and no idea what I was trying to do, but I sure hope it worked.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Explanation==&lt;br /&gt;
{{incomplete|Entry for 8 backslashes is just described, not explained. Title text is a block, could use a bit of restructuring.}}&lt;br /&gt;
&lt;br /&gt;
Most programming languages use the concept of a {{w|String literal|string}} literal, which is just a text between some delimiters, usually quotes. For example, &amp;quot;Hello, world&amp;quot; is a string literal. The text being represented is &amp;quot;Hello, world&amp;quot; without the quotes, however the quotes are also written to mark the beginning and end of the string. This is a problem when the text itself contains a quote, as in &amp;quot;This is a &amp;quot;quoted&amp;quot; string&amp;quot;. The quotes around the word &amp;quot;quoted&amp;quot; are intended to be part of the text, but the {{w|Lexical analysis|language processor}} will likely confuse it for the end of the string.&lt;br /&gt;
&lt;br /&gt;
To avoid this problem, an {{w|Escape character|escape character}} (usually a backslash) is prepended to non-string-terminating quotes. So, the previous text would be written as &amp;quot;This is a \&amp;quot;quoted\&amp;quot; string&amp;quot;. The language processor will substitute every occurrence of \&amp;quot; with only the quote character, and the string terminates at the quote character which does not immediately follow a backslash. However, the problem now is that the intended text might contain a backslash itself. For example, the text &amp;quot;C:\&amp;quot; will now be interpreted as an unterminated string containing a quote character. To avoid this, literal backslashes also are escaped with a second backslash, i.e. instead of &amp;quot;C:\&amp;quot; we write &amp;quot;C:\\&amp;quot;, where the language processor interprets \\ as one single backslash and the quote terminates the string.&lt;br /&gt;
&lt;br /&gt;
This doubling of backslashes happens in most programming and scripting languages, but also in other syntactic constructs such as {{w|Regular expression|regular expressions}}. So, when several of these languages are used in conjunction, backslashes pile up exponentially (each layer has to double the number of slashes). A reasonable example would be a {{w|PHP}} script in a web server which writes {{w|JavaScript}} code to be run in the client. If the JavaScript code has to output a smiley for scratching one's head (i.e. &amp;lt;code&amp;gt;r:-\&amp;lt;/code&amp;gt; ), it would look like this:&lt;br /&gt;
 document.write (&amp;quot;r:-\\&amp;quot;);&lt;br /&gt;
However, since this JavaScript code is to be written through a PHP script, the PHP code would be:&lt;br /&gt;
 echo &amp;quot;document.write (\&amp;quot;r:-\\\\\&amp;quot;);&amp;quot;;&lt;br /&gt;
where:&lt;br /&gt;
* The word &amp;lt;code&amp;gt;echo&amp;lt;/code&amp;gt; is the PHP command for writing something&lt;br /&gt;
* The first quote starts the string&lt;br /&gt;
* The &amp;lt;code&amp;gt;document.write (&amp;lt;/code&amp;gt; (including the open parenthesis) is written literally&lt;br /&gt;
* The &amp;lt;code&amp;gt;\&amp;quot;&amp;lt;/code&amp;gt; following that is a literal quote to be written&lt;br /&gt;
* The &amp;lt;code&amp;gt;r:-&amp;lt;/code&amp;gt; is written literally&lt;br /&gt;
* The first two slashes produce one single slash&lt;br /&gt;
* The next two slashes produce another single slash&lt;br /&gt;
* The next &amp;lt;code&amp;gt;\&amp;quot;&amp;lt;/code&amp;gt; produces a literal quote character&lt;br /&gt;
* The close parenthesis and the semicolon are to be written literally&lt;br /&gt;
* The next quote finishes the string.&lt;br /&gt;
* The final semicolon terminates the &amp;lt;code&amp;gt;echo&amp;lt;/code&amp;gt; command&lt;br /&gt;
&lt;br /&gt;
So, the presented scenario has escalated from a simple &amp;lt;code&amp;gt;r:-\&amp;lt;/code&amp;gt; smiley to no less than five backslashes in a row without stepping out of the most common operations. If we go a bit further and try to write a {{w|Java (programming language)|Java}} program that outputs our PHP script, we'd have:&lt;br /&gt;
 System.out.println (&amp;quot;echo \&amp;quot;document.write (\\\&amp;quot;r:-\\\\\\\\\\\&amp;quot;);\&amp;quot;;&amp;quot;);&lt;br /&gt;
Here, we have 11 backslashes in a row: the first 10 produce the 5 we need in our PHP script, and the last one is for escaping the quote character.&lt;br /&gt;
&lt;br /&gt;
This kind of backslash explosion is known as {{w|Leaning toothpick syndrome}}, and can happen in many situations. The one in the title text is about a {{w|Bash (Unix shell)|bash}} command (which uses the backslash to escape arguments) invoking the {{w|grep}} utility which searches for text following a pattern specified by means of a regular expression (which also uses the backslash to escape special characters). This leads to 3 backslashes in a row in the command, which could easily become 7 backslashes in a row if the text being searched for also contains a backslash. Even advanced users who completely understand the concept often have a hard time figuring out exactly how many backslashes are required in a given situation. It is hopelessly frustrating to carefully calculate exactly the number of backslashes and then noticing that there's a mistake so the whole thing doesn't work. At a point, it becomes easier to just keep throwing backslashes in until things work than trying to reason what the correct number is.&lt;br /&gt;
&lt;br /&gt;
=== Entries in the list ===&lt;br /&gt;
* 1 backslash is appropriately named just &amp;quot;backslash&amp;quot;.&lt;br /&gt;
* 2 backslashes are labelled &amp;quot;real backslash&amp;quot; as they refer to an escaped backslash.&lt;br /&gt;
* 3 backslashes would refer to an escaped backslash followed by an unescaped one. The first two backslashes would combine to make a &amp;quot;real backslash&amp;quot; while the third one would combine with the character following it to form an {{w|Escape sequence|escape sequence}}. The name &amp;quot;''real'' real backslash&amp;quot; does not make a lot of sense, as this is two escape sequences and not a single &amp;quot;very real&amp;quot; one.&lt;br /&gt;
* 4 backslashes form one single backslash escaped twice (the first escaping produces two backslashes, the second escaping doubles each of the backslashes). This is so common that even the [https://docs.python.org/2/library/re.html documentation for the Python regular expression library] mentions it explicitly. In this case, the backslash has to be escaped once for being part of a regular expression and then once more as the regular expression is inside a {{w|Python (programming language)|Python}} string. So this is named an &amp;quot;actual backslash, for real this time&amp;quot; as previous examples didn't contain enough escaping.&lt;br /&gt;
&lt;br /&gt;
From 5 backslashes onwards the comic goes to occult explanations and does not refer any more to real uses of backslash escapes.&lt;br /&gt;
&lt;br /&gt;
* 5 backslashes would be a doubly-escaped backslash plus an unescaped one. The reference to {{w|Elder}} in the comic has many meanings. It has become known through fantasy media; examples are the {{w|Elder Gods}} of the {{w|Cthulhu Mythos}}, various 'Elder' magical items and beings in the {{w|Dungeons and Dragons}} mythologies, and the {{w|Elder Days}}, which are the first Ages of {{w|Middle-earth}} in {{w|The Silmarillion}}, the more-or-less prequel to {{w|The Lord of the Rings}}. More recently it has been used in the {{w|Harry Potter}} universe with the {{w| Magical_objects_in_Harry_Potter#Deathly_Hallows|Elder wand}} made from {{w|Sambucus|Elder wood}}.&lt;br /&gt;
* 6 backslashes are said to &amp;quot;escape the screen and enter your brain&amp;quot;, which is a play on the word &amp;quot;escape&amp;quot; as the backslash is supposed to be an &amp;quot;escape character&amp;quot; but obviously not &amp;quot;escaping the screen&amp;quot;.&lt;br /&gt;
* 7 backslashes go further than escaping the screen and {{w|Transcendence (philosophy)|transcend}} {{w|Spacetime|time and space}}&lt;br /&gt;
* 8 backslashes would be a triply-escaped backslash (same as 4 backslashes but with an additional escaping layer). It is said to &amp;quot;end all other text&amp;quot;.&lt;br /&gt;
* 11 backslashes followed by &amp;quot;...&amp;quot; (to indicate they continue forever) are said to be ''The true name of {{w|Baal (demon)|Ba'al}}, the {{w|Soul eater (folklore)|Soul-Eater}}''. This indicates that if you continue misusing backslashes like this you will end up devoured by a demon, for instance {{w|Beelzebub}}, for being so thoughtless... Ba'al has been mentioned before in [[1246: Pale Blue Dot]] and [[1419: On the Phone]].&lt;br /&gt;
&lt;br /&gt;
=== Title text ===&lt;br /&gt;
It's unclear whether the regular expression in the title text is valid or not. A long discussion about the validity of the expression has occurred here on explainxkcd.com. The fact that many editors of the site, often themselves extremely technically qualified (citation needed for any evidence of this), can't determine whether the expression is valid or not adds a meta layer to the joke of the comic.  This is probably an example of [[356: Nerd Sniping|nerd sniping]] (oh, the irony!!!).&lt;br /&gt;
&lt;br /&gt;
==Transcript==&lt;br /&gt;
:[A list of the names of different numbers of backslashes. After each &amp;quot;item&amp;quot; there is a gray line to the text describing each item. As the text is aligned above each other, the lines becomes shorter as the sequence of backslashes becomes longer until there is just a line with the length of a single hyphen for the last item. There are 1 to 8 backslashes and then 11 plus &amp;quot;...&amp;quot; in the last entry.]&lt;br /&gt;
:\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;------------&amp;lt;/font&amp;gt; Backslash&lt;br /&gt;
:\\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;-----------&amp;lt;/font&amp;gt; Real backslash&lt;br /&gt;
:\\\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;----------&amp;lt;/font&amp;gt; ''Real'' real backslash&lt;br /&gt;
:\\\\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;----------&amp;lt;/font&amp;gt; Actual backslash, for real this time&lt;br /&gt;
:\\\\\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;---------&amp;lt;/font&amp;gt; Elder backslash&lt;br /&gt;
:\\\\\\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;--------&amp;lt;/font&amp;gt; Backslash which escapes the screen and enters your brain&lt;br /&gt;
:\\\\\\\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;-------&amp;lt;/font&amp;gt; Backslash so real it transcends time and space&lt;br /&gt;
:\\\\\\\\&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;------&amp;lt;/font&amp;gt; Backslash to end all other text&lt;br /&gt;
:\\\\\\\\\\\...&amp;lt;font color=&amp;quot;gray&amp;quot;&amp;gt;-&amp;lt;/font&amp;gt; The true name of Ba'al, the Soul-Eater&lt;br /&gt;
&lt;br /&gt;
{{comic discussion}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Regex]]&lt;br /&gt;
[[Category:Programming]]&lt;/div&gt;</summary>
		<author><name>00pebuis</name></author>	</entry>

	</feed>