September 21st, 2000, 03:32 PM
I need some help with making a regular expression to search a string for a character (a frontslash) and replace it with another character (a backslash).
Would this be any different from search/replacing a letter or number?
September 21st, 2000, 08:05 PM
$string = "This is a test";
$replacement = ' /';
echo ereg_replace (" is", $replacement, $string);
September 21st, 2000, 08:59 PM
I had to add an extra backslash in $replacement, but it works like a charm!
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
$string = "C:/test/test.html";
$replacement = '';
echo ereg_replace ("/", $replacement, $string);
Thanks for the tip.