Thread overview
std.string.split("hello world", " ;")
Oct 02, 2005
bug
Oct 02, 2005
Derek Parnell
Re: std.string.split(
Oct 02, 2005
bug
Oct 02, 2005
JT
Oct 02, 2005
bug
Oct 03, 2005
Chris Sauls
solved use std.regexp.split Re: std.string.split(
Oct 03, 2005
bug
October 02, 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



October 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
October 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 ,.;");




October 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 ,.;");   
> 
> 
October 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
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 ,.;");
>> 
>> 
>> 
>> 



October 03, 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
October 03, 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