Parsing strings from binary data #377
-
I'm parsing a portion of
I'm specifically looking to get the locations of the two 32-character ID strings, which I'm going to partly do with an updated version of this answer: #69 (comment). But: how can I parse string-like sequences out of a blob of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
To give a simpler example, say I had the following text, encoded as UTF-8
If I wanted to make a parser that took |
Beta Was this translation helpful? Give feedback.
All of the parsers that come with the library are super generic and can work on almost any kind of collection (usually where
C.SubSequence == C
, e.g.Substring
,UTF8View
, etc.). AndData
is such a collection, thoughArraySlice<UInt8>
would probably be a little more efficient to deal with.And so when you form a parser like this:
…that represents consuming all of the bytes up to and including the first occurrence of the subsequence of "<<" bytes in the input. And the
PrefixUpTo
parser does something similar, except it does not consume the delimiter bytes.So, in your simplified example, you might want something like this: