in reply to Extract pattern match from file
Hi kepler,
Try Regexp::Common:
use warnings; use strict; use Regexp::Common qw/delimited/; while (<DATA>) { while (/$RE{delimited}{-delim=>'"'}{-keep}/g) { my $str = $3; print "<$str>\n"; } } __DATA__ nothing "hello" foo "bar" quz "hello" "world" foo "bar" quz "baz" blah "" blah "" blah nothing
Outputs:
<hello> <bar> <hello> <world> <bar> <baz> <> <>
There's also the core module Text::Balanced, but I don't like its API as much.
Hope this helps,
-- Hauke D
|
|---|