View Single Post
Old 10-19-2020, 04:56 AM  
just a punk
So fuckin' bored
 
just a punk's Avatar
 
Industry Role:
Join Date: Jun 2003
Posts: 32,381
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.

So, 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.

E.g. is the qsort algorithm the fastest and optimized one? You may say "not", because we can find lot of cases when it will be slow like a turtle, but... in general cases it faster that other more specific sorting algos. The same applies to regexp. Sometimes (in simplest cases) it really slower, but in general cases when you work with patterns, it's the fastest method. Don't you agree? ;)
__________________
Obey the Cowgod
just a punk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote