odd behavior of split() function

Bedros 2bedros at gmail.com
Fri Jun 7 00:18:57 PDT 2013


I would like to split "A+B+C+D" into "A", "B", "C", "D"

but when using split() I get

"A+B+C+D", "B+C+D", "C+D", "D"


the code is below


import std.stdio;
import std.string;
import std.array;

int main()
{
      string [] str_list;
      string test_str = "A+B+C+D";
      str_list = test_str.split("+");
      foreach(item; str_list)
              printf("%s\n", cast(char*)item);

      return 0;
}


More information about the Digitalmars-d-learn mailing list