Monday, October 29, 2007

Perl regular expressions

(a*b*)* in perl == ((a*b*)*)

matches can be accessed in internal var$ $1,..$n
complete match is in $&

[a-zA-Z0-9] = \w

(\w*) = macthes anything alphanumeric + "_"

$line =~ m/((\w*-*)*)/; will match combinations of above plus "-"
$result = $1;
or
$result = $line =~ m/((\w*-*)*)/;

No comments: