Escape Sequences
Part of TutorialIntermediate
Description
Escape sequence are useful, but they can get tricky.
Demonstrates how to use escaping to put backslashes and apostrophes for a literal character.
Example
import std.stdio; const string backslashWYSIWYG = `\`; const string quoteWYSIWYG = `'`; const string doubleQuoteWYSIWYG = `"`; const string doubleQuoteReg = "\""; const string quoteReg = "\'"; const string backslashReg = "\\"; const char quoteChar = '\''; const char backslashChar = '\\'; const string rawString = r"\\\"; void main() { writeln(doubleQuoteReg ~ "That's what I said!" ~ doubleQuoteReg); writeln("raw string: ", rawString); }
Note that you can use the r"literalstring" form to stop treating backlash as an escape sequence character.
Partial Source
Link | http://jcc_7.tripod.com/d/tutor/escape.html |
Author | jcc7 |