Php 编译失败:缺少字符类的[1]

Php 编译失败:缺少字符类的[1],php,preg-split,Php,Preg Split,不确定为什么PHP会持续抛出丢失终止]错误 $date could be "23/09/2012" or "23-09-2012" or "23\09\2012" preg_split('/[\/\-\\]/', $date); 请执行以下操作,以消除歧义 preg_split('/[\/\-\\]/', $date); ^escaping the closing ']' 无需转义-,但也可以使用\- 代码: 输出: $date = 'as\sad

不确定为什么PHP会持续抛出
丢失终止]错误

$date could be "23/09/2012" or "23-09-2012" or "23\09\2012" 
preg_split('/[\/\-\\]/', $date);
请执行以下操作,以消除歧义

preg_split('/[\/\-\\]/', $date);
                   ^escaping the closing ']' 
无需转义
-
,但也可以使用
\-


代码:

输出:

$date = 'as\sad-s/p';
$slices =  preg_split('/[\/\-\\\\]/', $date);
print_r($slices);

你需要转义连字符吗?@Xin Old regex有个错误。请参阅更新的答案。很抱歉。@Xin Chen:我的正则表达式有一个错误,因为它没有在“\”处拆分。请参阅更新的答案。
$date = 'as\sad-s/p';
$slices =  preg_split('/[\/\-\\\\]/', $date);
print_r($slices);
Array ( [0] => as [1] => sad [2] => s [3] => p )