on Fri, 07 Jun 2002 15:02:36 GMT, [EMAIL PROTECTED] (Robert Hanson) wrote:
> $line =~ /'([^']*)'/; > print $1; > The regex is OK, but you should always check the return value of the match, as in print $1 if $line =~ /'([^']*)'/; because $1 will keep the value from a previous match if it fails, leading to incorrect results. Consider e.g. the following code: my @lines = ("'here is a quote'. Author etc etc", "Oops, no quote"); my $i=0; for my $line (@lines) { $i++; $line =~ /'([^']*)'/; print "line $i, quote is: $1\n"; } Which prints incorrectly: line 1, quote is: here is a quote line 2, quote is: here is a quote -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]