Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changes from Version 1 of EscapeSequencesExample/D2

Show
Ignore:
Author:
Andrej08 (IP: 78.2.39.16)
Timestamp:
09/07/10 02:26:04 (14 years ago)
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • EscapeSequencesExample/D2

    v0 v1  
     1= Escape Sequences = 
     2 
     3''Part of'' TutorialIntermediate 
     4 
     5== Description == 
     6 
     7Escape sequence are useful, but they can get tricky. 
     8 
     9Demonstrates how to use escaping to put backslashes and apostrophes  
     10for a literal character. 
     11 
     12== Example == 
     13 
     14{{{ 
     15#!d 
     16import std.stdio; 
     17 
     18const string backslashWYSIWYG = `\`; 
     19const string quoteWYSIWYG = `'`; 
     20const string doubleQuoteWYSIWYG = `"`; 
     21 
     22const string doubleQuoteReg = "\""; 
     23const string quoteReg = "\'"; 
     24const string backslashReg = "\\"; 
     25 
     26const char quoteChar = '\''; 
     27const char backslashChar = '\\'; 
     28 
     29const string rawString = r"\\\"; 
     30 
     31void main() 
     32{ 
     33    writeln(doubleQuoteReg ~ "That's what I said!" ~ doubleQuoteReg);   
     34    writeln("raw string: ", rawString); 
     35} 
     36}}} 
     37 
     38Note that you can use the '''r"''literalstring''"''' form to stop treating backlash as an escape sequence character. 
     39 
     40== Partial Source == 
     41 
     42|| Link || http://jcc_7.tripod.com/d/tutor/escape.html || 
     43|| Author || jcc7 || 
     44