On Thu, 2009-01-08 at 20:25 -0800, howa wrote:
> Hello,
> 
> 
> Consider the string:
> 
> $s = '[[2003]] abc [[2008]] "def"';
> 
> 
> I want to extract 2008 and def, so using
> 
> 
> \[\[([\w\W^\]]+?)\]\]\s"(.+?)"
> 
> The regex match all string, even thought I have added to exclude: ^\]
> inside the character class.
> 
> Any idea?
> 
> Thanks.
> 
> 

#!/usr/bin/perl

use strict;
use warnings;

my $s = '[[2003]] abc [[2008]] "def"';
$s =~ m{ \[\[ ( [[:digit:]]+ ) \] \] \s* \" (.*?) \" }msx;
print "\$1 = $1\n";
print "\$2 = $2\n";

-- 
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication as it is about 
coding.

"It would appear that we have reached the limits of what it is possible to 
achieve with computer technology, although one should be careful with such 
statements, as they tend to sound pretty silly in 5 years."
  --John von Neumann, circa 1950



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to