I would like to replace all characters in a string other than [a-zA-Z0-9\-]
with a space.
I've found this post and no matter how many times I tweak the REGEX, I can't get it to "don't match [a-zA-Z0-9-], only match and replace other characters".
At the moment, I have the following:
$original_name = trim(' How to get file creation & modification date/times in Python? ');
$replace_strange_characters = preg_replace("/^((?!([a-zA-Z0-9\-]+)*))$/", " ", $original_name);
// Returns: How to get file creation & modification date/times in Python?
echo $replace_strange_characters;
I wish for it to replace all of the strange characters with a space ' ', thus returning:
How to get file creation modification date times in Python?
I'm really struggling with these "don't match" scenarios.
Here's my code so far: http://tehplayground.com/#2NFzGbG7B