在php中使用正则表达式查找结果str

yoz*_*hik 2 php regex preg-replace preg-match

我有一个输入字符串:

$str1 = "some usefull text and garbage `~#@!&^*(()}{./";
$str2 = "`~#@!&^*(()}{./";

$result = Exclude with regular expressions all symbols from str1, which are in str2.
$result = "some usefull text and garbage";
Run Code Online (Sandbox Code Playgroud)

什么正则表达式将删除我指定的所有符号?如何以正确的方式过滤它?感谢名单!

net*_*der 5

您不需要正则表达式:

$clean_str = str_replace(str_split($str2), '', $str1);
Run Code Online (Sandbox Code Playgroud)

您可能想要trim生成的字符串.