in reply to Re: Problem with inline replace
in thread Problem with inline replace

Your observation that assignment rather than using substitution is exactly on track! Great job!

As far as performance goes, my experience is that split is an "expensive thing" CPU wise. A regex that tests whether a line starts with X is a relatively inexpensive thing. I have also found that the join() operation is very performant - i.e. joining 12 things together is way faster than splitting one thing into 12 things. Anyway I think the performance enhancement here is to not do a split at all unless you have to - my code is shown below which uses a regex to decide whether to split or not split.