To avoid a newline in multi-line strings
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sat Jul 23 08:24:14 PDT 2011
import std.algorithm;
import std.stdio;
import std.string;
string stripNewlines(string text)
{
auto x = text.countUntil("\n");
auto y = text.lastIndexOf("\n");
return text[x+1..y];
}
template EOS(string text)
{
enum EOS = stripNewlines(text);
}
void main()
{
writeln(EOS!"
- First item: 150
- Second item: 200
- Third item: 105
");
}
More information about the Digitalmars-d
mailing list