如何使用preg_split()删除方括号


How to remove Square brackets using preg_split()?

我有这样的表达式:

The Exorcist's [Restored Version] (xvid110-sickboy88)

想要这样的输出:

The Exorcist's Restored Version xvid110 sickboy88

请帮忙,提前谢谢。

不需要正则表达式。str_replace()会做这项工作。如果它的第一个参数是数组,而第二个参数是字符串,则第一个数组的所有元素都将被第二个字符串参数替换。

$input = "The Exorcist's [Restored Version] (xvid110-sickboy88)";
$str = str_replace(array("[", "]", "(", ")"), "", $input);
echo $str;
// The Exorcist's Restored Version xvid110-sickboy88
       $string = "The Exorcist's [Restored Version] (xvid110-sickboy88)";
       $simbols = array("[", "]", "(", ")");
       echo str_replace($simbols , "", $string);

*试试这个。。。。。。。。在中间方括号前使用前斜杠*

$keywords=preg_split("/[[]/","[超文本]语言,编程");

print_r($keywords);