News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

regex question

Started by Metho, August 04, 2003, 04:02:32 AM

Previous topic - Next topic

Metho

Just because I'm curious now, in what kind of situation would preg_replace be slower than ereg_replace, if ever?

Methonis
Joshua "Methonis" Frazer
Support Specialist
The Simple Machines Team

Zef Hemel

I think preg is always faster, but I never really tested.

Metho

Hmm, okies. Just wondering because on php.net in the ereg_replace() help it says that OFTEN preg_replace() was faster, so I was just curious if there were actually any times when it wouldn't be. (As I see preg_replace 99.99% of the time, and every once in a while will see ereg_replace)

Thanks,

Methonis
Joshua "Methonis" Frazer
Support Specialist
The Simple Machines Team

[Unknown]

Ereg syntax can be clearer, but the engine behind it is less optimized and slower so it is almost always worse.

-[Unknown]

Metho

Got it, thanks. ;)

Methonis
Joshua "Methonis" Frazer
Support Specialist
The Simple Machines Team

Iridium

Seeing as ereg_* functions are "Extended POSIX syntax" and preg_* are "Perl syntax" I imagine that it's possible for there to be certain things that can be done using ereg_* that can't be done directly with preg_* and in those cases, ereg_* may be faster.

Advertisement: