September 11, 2014
On Thursday, 11 September 2014 at 21:54:39 UTC, Nordlöw wrote:
> Anyway, it shouldn't be too hard to express this in a new range.

I guess what we need is a variant of splitter with a more greedy alias template parameter that will digest two or one bytes.
September 11, 2014
On Thu, Sep 11, 2014 at 10:31:33PM +0000, "Nordlöw" via Digitalmars-d-learn wrote:
> On Thursday, 11 September 2014 at 21:54:39 UTC, Nordlöw wrote:
> >Anyway, it shouldn't be too hard to express this in a new range.
> 
> I guess what we need is a variant of splitter with a more greedy alias template parameter that will digest two or one bytes.

Why not just use std.regex?

	foreach (line; myInput.split(regex(`\n|\r\n|\r`)))
	{
		...
	}


T

-- 
The problem with the world is that everybody else is stupid.
September 12, 2014
On Thursday, 11 September 2014 at 22:39:40 UTC, H. S. Teoh via Digitalmars-d-learn > Why not just use std.regex?
>
> 	foreach (line; myInput.split(regex(`\n|\r\n|\r`)))
> 	{
> 		...
> 	}
>
>
> T

I'll try the lazy variant of std.regex

 	foreach (line; myInput.splitter(regex(`\n|\r\n|\r`)))
 	{
 		...
 	}

I wonder if this is compatible with a ctRegex aswell. I'll try later.

See also: http://dlang.org/phobos/std_regex.html#.splitter

Thx
September 12, 2014
On Thursday, 11 September 2014 at 22:39:40 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
> 	foreach (line; myInput.split(regex(`\n|\r\n|\r`)))

Shouldn't you use

 	foreach (line; myInput.split(regex("\n|\r\n|\r")))

here?
September 12, 2014
On Friday, 12 September 2014 at 13:25:22 UTC, Nordlöw wrote:
> On Thursday, 11 September 2014 at 22:39:40 UTC, H. S. Teoh via Digitalmars-d-learn wrote:
>> 	foreach (line; myInput.split(regex(`\n|\r\n|\r`)))
>
> Shouldn't you use
>
>  	foreach (line; myInput.split(regex("\n|\r\n|\r")))
>
> here?

Probably not, as (AFAIK) the splitter engine *itself* will *also* escape the passed in characters. IE: It literally needs the characters '\' and 'n'.
September 12, 2014
On Friday, 12 September 2014 at 14:16:07 UTC, monarch_dodra wrote:
> Probably not, as (AFAIK) the splitter engine *itself* will *also* escape the passed in characters. IE: It literally needs the characters '\' and 'n'.

I ended up with this.

https://github.com/nordlow/justd/blob/30806a85a5c976f3e891ca11bde3d87a16ecf5e6/algorithm_ex.d#L1858

Does it seem ok?
1 2
Next ›   Last »