in reply to Re^3: How to remove everything after last occurrence of a string?
in thread How to remove everything after last occurrence of a string?

It comes down to choosing the right tool for the task at hand. That is an art in itself. Often a regex is the right tool to solve a tricky matching problem. Sometimes something like index is the tool to use for a simple matching problem or where speed is critical. My main point is that raw execution speed should not be the first consideration when choosing tools to solve a problem. Demonstrable correctness and maintainability should come first and often go hand in hand. At this point the discussion doesn't have much to do with the OP or the specific implementation of any reply.

My reply was addressing what could be seen as a "speed first" approach to coding being advocated by kcott's reply. Ken is an experienced coder so he can skip a few iterations ahead to get a solution that is both clean and quick. That is something that comes with experience, often bitter, so I thought a heads up for the less experienced was in order.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
  • Comment on Re^4: How to remove everything after last occurrence of a string?

Replies are listed 'Best First'.
Re^5: How to remove everything after last occurrence of a string?
by eyepopslikeamosquito (Archbishop) on Jun 08, 2022 at 09:49 UTC

    Demonstrable correctness and maintainability should come first ... My reply was addressing what could be seen as a "speed first" approach to coding being advocated

    Strongly agree! See: on Code Optimization

    Sadly, there seems to have been an increase lately in monks asking for faster code without explaining why speed matters for their problem and without providing a benchmark. Some reacted appallingly on being given your well-meaning advice, one even deleting all his content and leaving the monastery in a huff.