Skip to content

Newbie Question: parse a 4 digit year? #628

Closed Answered by zesterer
cmbothwell asked this question in Q&A
Discussion options

You must be logged in to vote

digits parses as many digits as it can in one go: so the very first time it's invoked, it's consuming every digit and then the remaining 3 attemts at consuming digits have nothing left to consume, hence 'found end of input'. Consider using the following instead:

filter(char::is_digit).repeated().exactly(4)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@cmbothwell
Comment options

@zesterer
Comment options

Answer selected by cmbothwell
@cmbothwell
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants