Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Multiline Regex Issue

by jaldama (Acolyte)
on Feb 02, 2012 at 18:37 UTC ( #951506=perlquestion: print w/ replies, xml ) Need Help??
jaldama has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to extract a string that is found between [] brackets on multiple lines, but I can't seem to get it right. Any advice?

if ($file =~ m/\[(.*?)\]/m ) { my $inside = $1; print "$inside\n"; }

The $file looks something like this:

Something [ 'name', 'joe', 'bopeep' ]

Comment on Multiline Regex Issue
Select or Download Code
Re: Multiline Regex Issue
by moritz (Cardinal) on Feb 02, 2012 at 19:11 UTC
      Obligatory docs link: Modifiers

      The OP's input looks suspiciously like JSON, in which case they should consider using the JSON module.

      n00b mistake

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://951506]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2015-07-05 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls