digitalmars.D.bugs - std.string.split("hello world", " ;")
- bug d.com (14/14) Oct 02 2005 $ cat strsplit.d
- Derek Parnell (8/24) Oct 02 2005 What bug? Or did you mean to code ...
- bug d.com (7/12) Oct 02 2005
- JT (3/18) Oct 02 2005 where do you get the idea its supposed to do that? thats not what split
- bug d.com (20/41) Oct 02 2005 I've thought:
- Chris Sauls (3/15) Oct 02 2005 Not yet, although it would be useful.
- bug d.com (14/15) Oct 03 2005 import std.regexp;
$ 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 worldWhat 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 theidea its supposed to do that? thats not what splitdoes, you specify theactual delimiter.bug d.com wrote:..What bug? Or did you mean to codechar[][] 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