3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = [ "tesT StriNg%&/()=?aj-hd_86b", "tesTStriNgaj-hd_86b" ]; foreach ($test as $str) { echo (!preg_match("/[^[:alnum:]\-_]/",$str)) ? $str." is valid.\n" : $str." is NOT valid.\n"; } ?>

preferences:
49.06 ms | 402 KiB | 5 Q