in reply to regular expressions help

Here's a little script that might illustrate some of concepts presented by the other monks:

use strict; my @data = <DATA>; print "1:\n"; #1: print lines that contain something like '[[106535 abc]]' foreach my $line (@data) { print $line if $line =~ /\[\[\d+ \w+\]\]/; } print '-' x 20, "\n2:\n"; #2: print lines that start with something like '[[106535 abc]]', but #with an indeterminate number of brackets foreach my $line (@data) { print $line if $line =~ /^\[+\d+ \w+\]+/; } print '-' x 20, "\n3:\n"; #3: print lines that start with something like '[[106535 abc]]' foreach my $line (@data) { print $line if $line =~ /^\[\[\d+ \w+\]\]/; } print '-' x 20, "\n4:\n"; #4: print lines that start with two brackets, six digits, #a space, three alphanumerics and two brackes foreach my $line (@data) { print $line if $line =~ /^\[\[\d{6} \w{3}\]\]/; } print '-' x 20, "\n5:\n"; #5: print out the value inside of the brackets and then #the rest of the line foreach my $line (@data) { print "$1 - $2\n" if $line =~ /^\[\[(\d+ \w+)\]\]\s(.+)/; } __DATA__ [[106535 abc]] blah blah blah... [[298727 xyz etc etc etc etc etc [[093 hij]] so on and so on and so on [[459313 def] more more more more 459313 yadda yadda yadda yadda yadda [[349581 wxy]] yack yack yack yack yack they're coming to [[549412 qqq]] me away ipsum plurum ipsum plurum ipsum plurum ... ... ... ...
Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"