0

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!
Anyways:

$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;
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by ShawnCplus
Featured Replies
  • If you want everything accept for letters and numbers you can use [code=php] $pattern = '/[^a-z0-9]/i';[/code] If you are specific about \/:"?<*>| then it's this [code=php] $pattern = '#[\/:"\?<\*>|]#';[/code] Read More

1

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 = '#[\/:"\?<\*>|]#';
Comments
Thanks for the solution.
0

Thanks for the solution.

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

Thankyou.

This question has already been answered. Start a new discussion instead.
Be sure to adhere to our posting rules.