in reply to Extract pattern match from file
It is also worth pointing out that double quotes are not regular expression meta-characters and do not need to be escaped.
johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -E ' open my $inFH, q{<}, \ <<EOD or die $!; nothing "hello" foo "bar" quz "hello2" "world" foo2 "bar2" quz2 "baz" blah blah2 "" blah3 many lines of unquoted stuff "example 1 for instance" EOD my $data = do { local $/; <$inFH>; }; close $inFH or die $!; say qq{-->$1<--} while $data =~ m{"([^"]*)"}g;' -->hello<-- -->bar<-- -->hello2<-- -->world<-- -->bar2<-- -->baz<-- --><-- -->example 1 for instance<-- johngg@shiraz:~/perl/Monks >
I hope this is helpful.
Cheers,
JohnGG
|
|---|