digitalmars.D.bugs - std.string.split("hello world", " ;")
- bug d.com Oct 02 2005
- Derek Parnell <derek psych.ward> Oct 02 2005
- bug d.com Oct 02 2005
- JT <jtd514 ameritech.net> Oct 02 2005
- bug d.com Oct 02 2005
- Chris Sauls <ibisbasenji gmail.com> Oct 02 2005
- bug d.com Oct 03 2005
$ cat strsplit.d
import std.string;
int main(char[][] args) {
char[][] words = std.string.split("hello world", " ;");
printf("%d\n", words.length);
foreach (char[] w; words) {
printf("%.*s\n", w);
}
return 0;
}
output:
$ ./strsplit.exe
1
hello world
Oct 02 2005
On Sun, 2 Oct 2005 07:01:02 +0000 (UTC), bug d.com wrote:$ cat strsplit.d import std.string; int main(char[][] args) { char[][] words = std.string.split("hello world", " ;"); printf("%d\n", words.length); foreach (char[] w; words) { printf("%.*s\n", w); } return 0; } output: $ ./strsplit.exe 1 hello world
What bug? Or did you mean to code ... char[][] words = std.string.split("hello world", " "); That is, the delimiter of " " rather than " ;" -- Derek Parnell Melbourne, Australia 2/10/2005 6:20:12 PM
Oct 02 2005
What bug? Or did you mean to code ... char[][] words = std.string.split("hello world", " "); That is, the delimiter of " " rather than " ;"
I mean use multiple chars (or-ed) as delimiters (I think that's the intended semantics of split(str, delim), correct me if I'm wrong). char[][] words = std.string.split("hello world", "\t\r\n\v ,.;");
Oct 02 2005
where do you get the idea its supposed to do that? thats not what split does, you specify the actual delimiter. bug d.com wrote:What bug? Or did you mean to code ... char[][] words = std.string.split("hello world", " "); That is, the delimiter of " " rather than " ;"
I mean use multiple chars (or-ed) as delimiters (I think that's the intended semantics of split(str, delim), correct me if I'm wrong). char[][] words = std.string.split("hello world", "\t\r\n\v ,.;");
Oct 02 2005
I've thought: char[][] words = std.string.split(str); ==== char[][] words = std.string.split(str, "\t\r\n\v "); and then generalize the idea. So is there any function provide the semantics I'm looking for? In article <dhp5e0$bmd$1 digitaldaemon.com>, JT says...where do you get the
does, you specify the
bug d.com wrote:What bug? Or did you mean to code
char[][] words = std.string.split("hello world", " "); That is, the delimiter of " " rather than " ;"
I mean use multiple chars (or-ed) as delimiters (I think that's the intended semantics of split(str, delim), correct me if I'm wrong). char[][] words = std.string.split("hello world", "\t\r\n\v ,.;");
Oct 02 2005
bug d.com wrote:I've thought: char[][] words = std.string.split(str); ==== char[][] words = std.string.split(str, "\t\r\n\v "); and then generalize the idea. So is there any function provide the semantics I'm looking for?
Not yet, although it would be useful. -- Chris Sauls
Oct 02 2005
Not yet, although it would be useful.
import std.regexp; int main(char[][] args) { char[][] words = std.regexp.split("hello world", r" |or|;"); printf("%d\n", words.length); foreach (char[] w; words) { printf("%.*s\n", w); } return 0; } $ ./strsplit 3 hello w ld
Oct 03 2005








bug d.com