Quote:
Originally Posted by CyberSEO
Actually not  Depends on which operating system and which PHP engine you run it ;) And maybe in this particular case your code will be a bit faster (but the PHP code itself is larger). However in the more complicated cases (which we usually have a deal with, right?), regexp is much more effective by speed and that's a fact.
If you want to do a string replace or find a fixed text, course you will be using simple string functions. But if you need to find some brain-breaking pattern, you will be using regexp. That's what it designed for.
|
You are right - regex has it's place when it's a more complicated thing. In this particular case though string replace is faster. Either way like I said we're battling over 1/10000th of a second so in reality it makes no difference.
It is interesting though how there's so many ways to do it and the huge variance in execution speed with one way taking 5-6x as long to execute despite basically being exactly the same thing.