When I run my snippet as posted, I get the following output:
extracted foo, bar, baz; left ...blah......blah...
Do you get something different when you run it? Or do you want something different from that?
When you try to use the "s{...}{}" expression in your own code, is it possible that your "raw binary data" (in "the baz part") might contain a byte value of 0x3C? This would be treated as a "<" character in the regex match, which would cause trouble. Something like this might work better in that case:
s{<file fiop="([^"]+)" length="([^"]+)"/>(.*?)</file>}{}s
(update: added the "s" modifier at the end, in case the raw binary stuff might contain a line-feed)
Note the question mark after ".*" -- that's the important thing that was missing from your initial attempt: it makes the wildcard match non-greedy (stops matching as soon as possible). |