On Thu, Jan 8, 2009 at 23:25, howa <howac...@gmail.com> 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.
^ only makes a character class negative if comes at the beginning of the class. Also, having both \w and \W is meaning less. You are saying to match characters in the \w class, characters not in the \w class, ^, and ] (and both ^ and ] are both part of \W). I believe you want: $s =~ /\[\[([^\]]+)]] "([^"]+)"/; -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/