Thread overview
Skiping whitespace
May 26, 2013
matovitch
May 26, 2013
matovitch
May 26, 2013
matovitch
May 26, 2013
Mr. Anonymous
May 26, 2013
Ali Çehreli
May 27, 2013
matovitch
May 26, 2013
Hello,

I am writting a simple parser for .obj file (mesh) and I would like to read 3 floats like this :

   1.1       2.2

3.3

So I tried file.readf("%*[ \n\t]%f%*[ \n\t]%f%*[ \n\t]%f",&x, &y, &z); who works with C function scanf but doesn't work here.

Is there a simple way to parse this text ?

It is said in std.format that "It's comparable to C99's vsprintf()". So it is useful for writting but it would have been great to have an other format to read which would support regexp.

Thanks.
May 26, 2013
I should have created this thread in "learning D"...:/

May 26, 2013
up ?
May 26, 2013
On Sunday, 26 May 2013 at 22:07:29 UTC, matovitch wrote:
> up ?

I think you'd better repost it on digitalmars.D.learn.
May 26, 2013
On 05/26/2013 05:03 AM, matovitch wrote:

> I am writting a simple parser for .obj file (mesh) and I would like to
> read 3 floats like this :
>
>     1.1       2.2
>
> 3.3
>
> So I tried file.readf("%*[ \n\t]%f%*[ \n\t]%f%*[ \n\t]%f",&x, &y, &z);
> who works with C function scanf but doesn't work here.
>
> Is there a simple way to parse this text ?

A single space character in the format specifier is a placeholder for zero or more whitespace characters:

import std.stdio;

void main()
{
    float x;
    float y;
    float z;

    auto file = File("deneme.txt");

    file.readf(" %s %s %s", &x, &y, &z);
}

Ali

May 27, 2013
On Sunday, 26 May 2013 at 23:32:36 UTC, Ali Çehreli wrote:
>
> A single space character in the format specifier is a placeholder for zero or more whitespace characters:
>
> import std.stdio;
>
> void main()
> {
>     float x;
>     float y;
>     float z;
>
>     auto file = File("deneme.txt");
>
>     file.readf(" %s %s %s", &x, &y, &z);
> }
>
> Ali

Great ! Thanks a lot.