Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Extract pattern match from file

by Marshall (Canon)
on Sep 17, 2016 at 17:02 UTC ( [id://1172015]=note: print w/replies, xml ) Need Help??


in reply to Extract pattern match from file

Hi Kepler,

I just tweaked your regex a bit and used test data from haukex. I like his regexp-common solution, but for something simple, you are close.

use warnings; use strict; my $data = do { local $/; <DATA> }; my @strings = $data =~ /\"([^\"]*)\"/g; print map{"<$_>\n"}@strings; =Prints <hello> <bar> <hello> <world> <bar> <baz> <> <> <example 1 for instance> =cut __DATA__ nothing "hello" foo "bar" quz "hello" "world" foo "bar" quz "baz" blah "" blah "" blah nothing "example 1 for instance"
Update: I saw the post from AnomalousMonk, re: "". That is why I changed the + to a * to handle that situation. And yes, if a quote went between 2 lines, the new line would get captured and have to be dealt with in some way.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1172015]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found