Which is more efficient, PHP string functions or regex in PHP?

后端 未结 9 1898
甜味超标
甜味超标 2020-12-06 16:48

I\'m writing PHP code to parse a string. It needs to be as fast as possible, so are regular expressions the way to go? I have a hunch that PHP string functions are more expe

9条回答
  •  旧时难觅i
    2020-12-06 17:11

    Depends on your needs. Most regular expression operations are faster than one would think and can even outperform builtin string functions in certain trivial operations. Note that I have the preg library in mind, not the builtin regex library, which is quite slow.

提交回复
热议问题