I can't benchmark right now, but I would think that the tr/// operator is likely to be faster than a regex. Having said that, 80,000 lines is not a very large input, I am not sure that there is really a need to optimize further what you have and you're going, at best, to shave off a split second.