split with delimiter
bioinfornatics
bioinfornatics at fedoraproject.org
Thu Feb 16 16:47:34 PST 2012
Le vendredi 17 février 2012 à 01:33 +0100, bioinfornatics a écrit :
> reading
> http://www.d-programming-language.org/phobos/std_array.html#split
>
> ---------------------------------------------------
> S[] split(S)(S s); // merge space together
>
> and
>
> Unqual!(S1)[] split(S1, S2)(S1 s, S2 delim); // do not merge delim
> together ?
>
> ---------------------------------------------------
>
>
> why the second split function do not merge delim together?
> how merge delim together?
>
Code to try
----------------------
import std.string;
import std.stdio;
import std.array;
void main( ){
string test = "hi\t\tD is fun";
string test2= "hi D is fun";
writeln( test.split("\t"));
writeln( test2.split() );
writeln( test2.split(" ") );
}
----------------------
Result
["hi", "", "D is fun"]
["hi", "D", "is", "fun"]
["hi", "", "D", "is", "fun"]
More information about the Digitalmars-d-learn
mailing list