How to read \n from a string

Stephen Jones siwenjo at gmail.com
Sat Nov 23 16:40:43 PST 2013


I want to be able to write a string containing \n to indicate 
newline breaks, but I want the string to cover multiple lines for 
example:

string str = "This is just a little string I wrote\n to see if 
all was upside down or not, or known to be back to front at all.";

if I use:

foreach(c; str){
   if(c == '\n') writeln("new line");
}

I get 2 prints of "new line", one for the \n and one for the new 
line. Is there any way to isolate the explicit \n?


More information about the Digitalmars-d-learn mailing list