3v4l.org

run code in 300+ PHP versions simultaneously
<?php $name = 'my file:name?w[ith/illegal*cha]racters\"that<are>not\allowed|here.txt'; $newName = preg_replace('/[\?\/:|<>*\[\]\(\)\$%\{\}@~\s]/', '_', $name); var_dump($newName);
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
string(69) "my_file_name_w_ith_illegal_cha_racters\"that_are_not\allowed_here.txt"

preferences:
45.69 ms | 406 KiB | 5 Q