I'm learning nom, and as a test example I'm trying to parse a string until a delimiter. If my delimiter is /
, then I want to match everything until that delimiter. For that, a parser like this works:
named!(gobbledygook, take_until!("/"));
I also want to match a string that ends before that delimiter, so I want both foo/bar
and foo
to return "foo". I can't seem to find anything suitable in the list of parsers and combinators.
I guess it would be possible to scan for either the delimiter or the end of the string, but it seems this is such a common case that there should be something obvious that I'm missing.