ereg_replace deprecated

Login or register to post comments
7 replies [Last post]
LaCeja's picture
Offline
Joined: 11/04/2009

Is there an update to the wiki tutorial for 1.1. I pretty much figured out everything, except that ereg_replace has been deprecated. I haven't figured out how to exchange it for preg_replace.

alex94040's picture
Offline
Joined: 11/06/2008

Removal of ereg_replace is not a QCubed 1.1 thing. It's a PHP 5.3 thing - see details here and here.

Google "preg tutorial" to learn about perl regular expressions.

LaCeja's picture
Offline
Joined: 11/04/2009

Thanks Alex. It was the leading and trailing slashes (/) that I didn't get before.

Basically, just change it from:

$contents = ereg_replace("( ){1}(([A-Z][a-z0-9]+){2,})", " \\2",

to:

$contents = preg_replace("/( ){1}(([A-Z][a-z0-9]+){2,})/", " \\2",

Thanks again!

alex94040's picture
Offline
Joined: 11/06/2008

Just to clarify: you had to make that change in your own code, not in QCubed framework code, right?

LaCeja's picture
Offline
Joined: 11/04/2009

The code in the wiki example doesn't work with php 5.3. It's not actually in QCubed, it's in the wiki 1st example for translating WikiWords to a link. Probably there should be a separate wiki example (tutorial) for QCubed 1.1 with php 5.3. So, the problem isn't with QCubed so much as it's using a deprecated php function. It works fine with php 5.2.9-11.

alex94040's picture
Offline
Joined: 11/06/2008

Can you point me to the URL of the example that's broken? On http://examples.qcu.be?

LaCeja's picture
Offline
Joined: 11/04/2009

Sure, it's in Building a Wiki, part1. Look for:

FindWikiWords

alex94040's picture
Offline
Joined: 11/06/2008

Got it! Makes sense. Feel free to make the edits yourself - it's a wiki! :)