Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scan macro doesn't capture whitespace into strings #32

Open
adnan449 opened this issue Dec 5, 2020 · 1 comment
Open

Scan macro doesn't capture whitespace into strings #32

adnan449 opened this issue Dec 5, 2020 · 1 comment

Comments

@adnan449
Copy link

adnan449 commented Dec 5, 2020

    let data = String::from("1-5 w:dsjvly wge");
    let min: i32;
    let max: i32;
    let c: char;
    let pw: String;
    scan!(data.bytes() => "{}-{} {}:{}", min, max, c, pw);
    dbg!(pw);

Here, pw returns dsjvly only, skipping wge. How should one get around this so the complete string gets captured?

@oli-obk
Copy link
Owner

oli-obk commented Dec 7, 2020

If your pattern finishes with with anything but a capture, then that would work. So if your data contained a trailing . and your pattern was also finished by a . then it would work. I guess we could change scan! to always parse to the end in case the pattern ends with a placeholder, but this would not really work for using scan! for stdin or any other infinite input source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants