September 17, 2017 How to Skip some field/word in formattRead? | ||||
---|---|---|---|---|
| ||||
Hi, Is it possible to read just the second word from an input string and skip all others? "one two three".formattedRead!("%s %s", _, saveme) The point is I want to skip the first/third word (`one`, `third`) and read the second word (`two`) into the variable `saveme`. For now I have to declare temporary reference string _; "one two three".formattedRead!("%s %s %s", _, saveme, _); Well, `_` is acceptable; in my example, the value of `_` would be `three[\n]` Is there any better/cleaner way? Thanks for your reading. |
September 17, 2017 Re: How to Skip some field/word in formattRead? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ky-Anh Huynh | On Sunday, 17 September 2017 at 13:53:26 UTC, Ky-Anh Huynh wrote:
> Is it possible to read just the second word from an input string and skip all others?
>
> "one two three".formattedRead!("%s %s", _, saveme)
---
import std.range;
auto saveme = "one two three".split.array [2];
---
|
Copyright © 1999-2021 by the D Language Foundation