http://www.perlmonks.org?node_id=951506

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' ]

Replies are listed 'Best First'.
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