On Monday 25 July 2005 01:56pm, Michael Stassen wrote:
Gregory Machin wrote:
Hi.
Please could you advise me...
I have php pages that are stored in a mysql database, that will later
be imported into a cms
I want to use mysql's regex funtion to remove unwanted php code and
update links to images
and urls.
But i cant seem to get my brian around the regex part ...
i want to remove the header include ?php require(./include/header1);?
i tried \?php[^][header1].*\? , and other attempts but no luck ..
unfortunetly i can do a normal string replace because of varations,in
the code ...
This regex would not match your case. Try this on for size:
\?php.*require.*header1.*\?
Many Thanks
MySQL's REGEX is only for matching, not for replacement. If you really
need a regex search and replace, you may find it easier to dump your data,
edit it, and reimport it. If you are determined to do it in mysql, you'll
need a (probably ugly) combination of mysql string functions. See the
manual for details:
http://dev.mysql.com/doc/mysql/en/string-functions.html
http://dev.mysql.com/doc/mysql/en/string-comparison-functions.html
As Michael suggests, better to do this in an app. It should not take you very
long to write a quick data importer in PHP that would take care of all this
including using preg_replace () where you want it.
--
Lamont R. Peterson [EMAIL PROTECTED]
Founder [ http://blog.openbrainstem.net/peregrine/ ]
OpenBrainstem - Intelligent Open Source Software Engineering
pgpzhFjg8ymNz.pgp
Description: PGP signature