<?php
$string = "test #$ test";
$not_acceptable_characters_regex = '#[^-a-zA-Z0-9_ ]#';
$string = preg_replace($not_acceptable_characters_regex, '', $string);
echo $string;
?>这段代码是剔除那些不是a-z, 0-9, -, _ 或空格的字符。我想问一下上面的正则表达式中为什么前后都有一个#?我的想法是'[^-a-zA-Z0-9_ ]',但试了一下,似乎不对。