If you want to know the results of each regex match (3 vs 18 as mentioned), then you must run them each in turn and record the results. Thusly, approach 2 is right out.
If your regex to match against are multiline matches, then you're getting down to just a loop over the list of regexes and matching against the whole file each time.
The best thing to do is benchmark the various options (while also ensuring that they return the correct results). In practice, I expect that the quality of the regexes input into your program will make all the difference in performance.
For example, during a set of straightforward substitutions against a huge file that I did a few weeks ago, it spent about 5 seconds to read the input and 5 seconds to write the results back to disk. And it took a total of 10 seconds to run.
On the other hand, if your input regexes are complicated messes with lots of backtracking and exponential time cost, you're hosed no matter what you do.
In reply to Re: Regular Expression (Regex) Sieve
by SuicideJunkie
in thread Regular Expression (Regex) Sieve
by Wiggins
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |