Parsing, token, regular expressions
Definitions
- Parsing — turning input (text, bytes) into a structure that's convenient to work with: JSON → model, string → number, HTML → DOM.
- A token in parsing is the smallest meaningful unit of input (a number, a name, a bracket); a lexer cuts text into tokens and a parser builds a structure from them. (Not to be confused with an auth token — the string the client sends in
Authorization: Bearer ....) - A regular expression is a pattern for finding and extracting substrings:
#(\d+)matches "#4521". In Swift 5.7+ that's the/.../literal andRegexBuilder; in Foundation,NSRegularExpression.
In an iOS context "parsing" almost always means JSON via Codable.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep