What I require is to replace \/:"?<*>| with a space.

I have done similar statements before but I have complete brain freeze at the moment. Hoping one of you can jog my memory. Always hated regex expressions never understood the logic behind them minus the A-Z and 0-9 and then all the brackets, etc. Blah!

$pattern = // This where I require the regex expression
$replacement = " ";
$string = "a\b/c:d*e?f"g<h>i|j";
$test_string = preg_replace($pattern, $replacement, $string);
echo $test_string;

If you want everything accept for letters and numbers you can use

$pattern = '/[^a-z0-9]/i';

If you are specific about \/:"?<*>| then it's this

$pattern = '#[\/:"\?<\*>|]#';
Thanks for the solution.

Thanks for the solution.

If you have any good sites to refresh my memory of this stuff let me know.


This question has already been answered. Start a new discussion instead.