Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我怎样才能实现这个来跳过字符,比如:! : \ & '在任何位置?
! : \ & '
preg_match_all('/#(\w+)/', $string, $matches);
如果您要使用如下模式,根据实现,您应该能够找到所有这些字符并将它们替换掉:
$teststring = "#!TEST'\&" $pattern = (!|&|\\|\') $replacement = '' echo preg_replace($pattern, $replacement, $teststring)
应该输出:
'#TEST'