Editing 1638: Backslashes

Jump to: navigation, search

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 14: Line 14:
 
However, the problem now is that the intended text might contain a backslash itself. For example, the text "C:\" 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 "C:\" we write "C:\\", where the language processor interprets \\ as one single backslash and the quote terminates the string to give ''C:\'' as the output.
 
However, the problem now is that the intended text might contain a backslash itself. For example, the text "C:\" 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 "C:\" we write "C:\\", where the language processor interprets \\ as one single backslash and the quote terminates the string to give ''C:\'' as the output.
  
βˆ’
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). See example of a backslash explosion and alternatives to avoid this [[#Backslash explosion and alternatives|below]].
+
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). See [[#Backslash explosion and alternatives|example of a backslash explosion and alternatives]] below.
  
 
This kind of backslash explosion is known as {{w|Leaning toothpick syndrome}}, and can happen in [[1313: Regex Golf|many situations]]. Below is an explanation of all the [[#Entries in the list|entries in the comic]].
 
This kind of backslash explosion is known as {{w|Leaning toothpick syndrome}}, and can happen in [[1313: Regex Golf|many situations]]. Below is an explanation of all the [[#Entries in the list|entries in the comic]].

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)