-
Suppose this is the input text: |
Beta Was this translation helpful? Give feedback.
Answered by
epage
Jul 18, 2024
Replies: 1 comment 7 replies
-
Is that regex literally what needs to be parsed, as in let input = "ab hhh fdfv hy tail1 tail2";
let (input, tail2) = input.rsplit_once(" ").unwrap();
let (head, tail1) = input.rsplit_once(" ").unwrap();
|
Beta Was this translation helpful? Give feedback.
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The main way people do backtracking is using
alt()
but that requires having distinct fallback cases. In the situation you gave, there doesn't seem to be distinct fallback cases. This is why I was asking for clarification to see if that was intended literally or if, with more information, we'd be able to identify fallback cases.I'm assuming there is more to the need of your parser than just this. In that case, Winnow is designed to allow you to drop down to writing parse code like this by hand, like the
rsplit_once
code I mentioned.One example is