[a-zA-Z0-9\-]
文字列内のすべての文字をスペース以外に置き換えたいと考えています。
この投稿を見つけましたが、REGEX を何度調整しても、「[a-zA-Z0-9-] に一致せず、他の文字のみに一致して置換する」ようにすることはできません。
現時点では、次のものがあります。
$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;
すべての奇妙な文字をスペース ' ' に置き換えて、次のように返したいと思います。
How to get file creation modification date times in Python?
私はこれらの「一致しない」シナリオに本当に苦労しています。
これまでの私のコードは次のとおりです。http://tehplayground.com/#2NFzGbG7B