Bill,
You are quite correct. You could use either.
Safer than :
if ($line=~/^(.*?)-/)
{
$beg_of_line = $1;
#do your other stuff with it...
}suggested by Elizabeth Lawrence.
I suppose I feel safer using [^-] because of certain scenarios when .* caused problems for me.
The same for using ?, the non-greedy notation.
That would then make me feel doubly safe.
Sorry, I can't recall what those scenarios were.
Paul
Paul Appleby wrote:
Michael,
This might be safer:
$line=~/^([^-]*?)-/;
$everything_to_first_hyphen=$1;
Why would that be ? And safer than what (you removed the RE you were referring to) ? The ? is redundant and I don't see why [^-]* would be any safer than .*?- (I might use either).
I'm sure this is obvious, but I'm missing it - What's the regular expression to extract everything from the start of the line to the first hyphen?
-- ,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED] (_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED] / ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/ -/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff) _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
-- Sincerely,
Paul Appleby
(416) 530-0070 http://www.paulappleby.com http://myspider.ca _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
