in reply to Re^2: extracting a substring from a string - multiple variables
in thread extracting a substring from a string - multiple variables

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).

Replies are listed 'Best First'.
Re^4: extracting a substring from a string - multiple variables
by walinsky (Scribe) on Oct 28, 2007 at 00:41 UTC
    where do I send the flowers ;)

    the 's' modifier at the end did the trick!

    thanks for your continuous effort (and updating your comment ;)