in reply to Re^4: Regular Expression - pattern matching
in thread Regular Expression - pattern matching
Update: Oh, one thing I forgot to point out, was that there was an error in the code in my earlier reply. I hadn't accounted for the fact that there may not be any underscores at all. That's been fixed in the above snippet.for (@strings) { my $temp = ""; if (($temp) = $_ =~ m/^([^_]{2}_[^_]+)_?/) { print $temp; } elsif (($temp) = $_ =~ m/^([^_]+)/) { print $temp; } }
|
|---|