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> &lt;<a href="mailto:krahnj@telus.net">krahnj@telus.net
</a>&gt; 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>&gt; Hi,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I'm having some trouble with a regular expression, and I thought I'd toss
<br>&gt; it out to the list, especially since it seems quiet here lately.<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I'd like to process a file line by line, capturing the everything from the<br>&gt; start of the line to a hash mark (#), which would indicate a comment. Here are
<br>&gt; some things I tried:<br>&gt;<br>&gt; my $line =~ /^(.*)\#?/; # this takes the entire line, as expected.<br>&gt;<br>&gt; my $line =~ /^(.*?)\#?/; # this works if there is a comment, but not if there<br>&gt; isn't. If there isn't a comment it captures the shortest match, which is
<br>&gt; nothing.<br>&gt;<br>&gt; 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>&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;MEETINGS: 3rd Tuesdays, Location: <a href="http://Amazon.com">Amazon.com</a> Pac-Med<br>&nbsp;&nbsp;&nbsp;&nbsp;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>