In a message dated 4/15/2004 7:13:09 PM Eastern Daylight Time, 
[EMAIL PROTECTED] writes:
>How can I write a regular expression to keep the part of a string that's
>between a pair of square braces?  Here's a sample line:
>
>Updating Wellbore Set Keys: [wlbr_id = 1234567890, data_provider_code =
>MTBL, welltype = OIL]

How does this sound?

my $string = q(Updating Wellbore Set Keys: [wlbr_id = 1234567890, 
data_provider_code = MTBL, welltype = OIL]);
my @matches = $string =~ m/\[(.*?)\]/g;
local $, = "\n";
print @matches;

-will
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone (a Godsend)
-Perl::Tidy
-Beautifier
-DBD::SQLite

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to