John W. Krahn wrote:
> Steve Bertrand wrote:
>> Hi everybody,
>
> Hello,
>
>> I am far from a regex guru, so I know that I can get advice on how to
>> learn to improve my regex knowledge so I can better my currently working
>> code to protect against failure in the future. I would appreciate some
>> criticism, with explanations as to the changes if possible.
>>
>> I've made it as brief as possible, with hopefully enough context (sorry
>> if it wraps):
>>
>>
>> while (<LOG>) {
>>
>> if (/.*simscan~\[\d+\]~([\w|\s]+).*?~(\d+\.\d+)s~.*?~(.*?)~(.*?)~(.*)/) {
>
> The .* pattern at the beginning is useless as it causes unnecessary
> back-tracking, just remove it.
That depends on the target data. If the rest of the regular expression matches
the target string in more than one place then preceding it with .* forces it to
match the last occurrence. Without that it matches the first occurrence.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/