This is specifically aimed at parsing hex bytes, but there's a more general question here.
Suppose I have a regexp r e.g. \\s*([0-9A-Fa-f]{2})\\s* (optional spaces, 2 hex digits that I'm interested in, and optional spaces).
If I want to parse a string s with this regexp such that:
if
scan be divided into a sequence of blocks that matchesr, I want to do something for each block. (e.g.ff 7c 0903 02BB aCcould be divided in this way.)If
scannot be divided accordingly, I want to detect this. (e.g.00 01 02 hi there ab ffand9 0 2 1 0andY0 DEADBEEFandcafe BABE!all fail.)
how could I do this with Java's regexp facilities?