|
Posted by Jürgen Exner on May 13, 2008, 5:14 pm
Please log in for more thread options >Jürgen Exner wrote:
>>> Andy wrote:
>>>> if ($line =~ m/^(.+226\s+0\s+-\s+.*)$/) {
>>> Matching ^.+ is wasteful.
>>> You don't need to capture the whole line using ().
>>>
>>>> print OUTPUT "$1\n";
>>> Unless you chomp your input you'll output an extra blank line.
>>
>> My first thought, too. However because of the rather 'interesting' way
>> he is printing the captured group instead of just the plain line he is
>> loosing the newline in the pattern match. Therefore he has to add it
>> back explicitely.
>
>The \s+ at the end is greedy and will match everything at the end
>including the newline unless there is a non-whitespace character after
>it that .* will match.
You are right. I was looking at the trailing .* only and didn't dissect
the RE beyond that.
This RE certainly has some Interesting side effects.
jue
|