SPUG: regular expression question
cconnoll at u.washington.edu
Mon Nov 14 22:29:34 PST 2005
I'm having some trouble with a regular expression, and I thought I'd toss
it out to the list, especially since it seems quiet here lately.
I'd like to process a file line by line, capturing the everything from the
start of the line to a hash mark (#), which would indicate a comment. Here are
some things I tried:
my $line =~ /^(.*)\#?/; # this takes the entire line, as expected.
my $line =~ /^(.*?)\#?/; # this works if there is a comment, but not if there
isn't. If there isn't a comment it captures the shortest match, which is
All suggestions are welcomed.
More information about the spug-list