On Wednesday, 10 September 2014 at 21:06:30 UTC, Nordlöw wrote:
This is such a common feature so I believe it should have its
place in std.range.
Or some other Phobos module.
On 09/10/2014 02:06 PM, "Nordlöw" wrote:
I'm missing a range variant of byLine that can operate on strings
instead of just File.
This is such a common feature so I believe it should have its place in
std.range.
My suggestion is to define this using
splitter!(std.uni.isNewline)
but I'm missing
On Wednesday, 10 September 2014 at 22:29:55 UTC, Ali Çehreli
wrote:
assert("foo\nbar\n"
.splitter(newline)
.filter!(a => !a.empty)
.equal([ "foo", "bar" ]));
}
Ali
Ok, great.
So I got.
auto byLine(Range)(Range input) if (isForwardRange!Range)
{
import
On Wednesday, 10 September 2014 at 22:45:08 UTC, Nordlöw wrote:
auto byLine(Range)(Range input) if (isForwardRange!Range)
{
import std.algorithm: splitter;
import std.ascii: newline;
static if (newline.length == 1)
{
return input.splitter(newline.front);
}
else
On Wednesday, 10 September 2014 at 23:01:44 UTC, Nordlöw wrote:
On Wednesday, 10 September 2014 at 22:45:08 UTC, Nordlöw wrote:
auto byLine(Range)(Range input) if (isForwardRange!Range)
{
import std.algorithm: splitter;
import std.ascii: newline;
static if (newline.length == 1)
{
On Thursday, 11 September 2014 at 10:19:17 UTC, monarch_dodra
wrote:
Well, the issue is that this isn't very portable for *reading*,
as even on linux, you may read files with "\r\n" line endings
(It's "standard" for csv files, for example), or read "\n"
terminated files on windows.
The issue is
On Thursday, 11 September 2014 at 20:03:26 UTC, Nordlöw wrote:
On Thursday, 11 September 2014 at 10:19:17 UTC, monarch_dodra
wrote:
Well, the issue is that this isn't very portable for
*reading*, as even on linux, you may read files with "\r\n"
line endings (It's "standard" for csv files, for e
On Thursday, 11 September 2014 at 21:29:16 UTC, monarch_dodra
wrote:
Bummer...
Anyway, it shouldn't be too hard to express this in a new range.
On Thursday, 11 September 2014 at 21:29:16 UTC, monarch_dodra
wrote:
Hum... no, those are the correct splitting elements. However, I
don't think that would actually work, as "find" will privilege
the first whole element to match as a "hit", so "\r\n" never be
hit (rather, it will be hit twice,
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.
On Thu, Sep 11, 2014 at 10:31:33PM +, "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
> temp
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.splitte
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?
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?
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/30806a85a5c976f3
15 matches
Mail list logo