The idea of using the "not character class" is well spelled out in
Curtis' (Ovid) post on perlmonks (<a href="http://perlmonks.org/?node_id=24640">http://perlmonks.org/?node_id=24640</a>).<br>
<br>
If you've not read it, I highly recommend it, and perlmonks for that matter.<br><br><div><span class="gmail_quote">On 11/14/05, <b class="gmail_sendername">John W. Krahn</b> <<a href="mailto:krahnj@telus.net">krahnj@telus.net
</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Charles Connolly wrote:<br>> Hi,<br>> I'm having some trouble with a regular expression, and I thought I'd toss
<br>> it out to the list, especially since it seems quiet here lately.<br>> I'd like to process a file line by line, capturing the everything from the<br>> start of the line to a hash mark (#), which would indicate a comment. Here are
<br>> some things I tried:<br>><br>> my $line =~ /^(.*)\#?/; # this takes the entire line, as expected.<br>><br>> my $line =~ /^(.*?)\#?/; # this works if there is a comment, but not if there<br>> isn't. If there isn't a comment it captures the shortest match, which is
<br>> nothing.<br>><br>> All suggestions are welcomed.<br><br>my $line =~ /^([^#]*)/;<br><br><br><br>John<br>--<br>use Perl;<br>program<br>fulfillment<br>_____________________________________________________________
<br>Seattle Perl Users Group Mailing List<br> POST TO: <a href="mailto:spug-list@pm.org">spug-list@pm.org</a><br>SUBSCRIPTION: <a href="http://mail.pm.org/mailman/listinfo/spug-list">http://mail.pm.org/mailman/listinfo/spug-list
</a><br> MEETINGS: 3rd Tuesdays, Location: <a href="http://Amazon.com">Amazon.com</a> Pac-Med<br> WEB PAGE: <a href="http://seattleperl.org/">http://seattleperl.org/</a><br></blockquote></div><br><br clear="all"><br>
-- <br>Ben Prew<br><a href="mailto:ben.prew@gmail.com">ben.prew@gmail.com</a>