in reply to File reading efficiency and other surly remarks
Oftimes, while I find that I can write a more efficient regex than one I find in a program that I am working on, I ask myself two questions:
For example in one script, I had to write the following regex:
Because of the nature of the data, I could have written (untested):$input =~ /^(?:[^_]|_(?!${value}))+_${value},((?:[A-Z]\d{1,2},?)+).*/;
The second regex may not be easy to understand, but it's a heck of a lot easier to understand then the first. If the script didn't require maximum efficiency, I would have chosen the second for maintainability.$input =~ /$value,((?:\w\d{1,2},?)+)/;
Cheers,
Ovid
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: (Ovid - when *not* to optimize) Re: File reading efficiency and other surly remarks
by tilly (Archbishop) on Aug 26, 2000 at 08:02 UTC |