Replace ' / ' character in string
Posted: Mon Feb 11, 2008 12:44 am
I am running a server-side script that is supposed to replace words in multiple files on my server, but I need the script to replace a string of characters which include the ' / ' (forward slash) character. Unfortunately, the forward slash is causing the script to bark an error code for every instance of the string found! When the forward slash is removed, no problems.
How do I rewrite the following script so that it finds and replaces a string of text that includes the ' / ' (forward slash) character??? Here is the original script:
*NOTE: The characters in red are what I need to find and then replace.
How do I rewrite the following script so that it finds and replaces a string of text that includes the ' / ' (forward slash) character??? Here is the original script:
Code: Select all
require_once('TextSearch.class.php');
$path = "/home/hsmhost/public_html/"; //setting path to search
$logFile = "log_result.txt"; //setting log file
$obj = new TextSearch();
$obj->setExtensions(array('php')); //setting extensions to search files within
$obj->addExtension('txt');//adding an extension
$obj->setSearchKey('[color=#BF0000]/__HS0108/images/head[/color]'); //what to search for
$obj->setReplacementKey('[color=#BF0000]/images/head[/color]');//setting replacement text if you want to replace matches with that
$obj->startSearching($path);//starting search
$obj->showLog();//showing log
$obj->writeLogToFile($logFile); //writting result to log file