Laravel Rules & Regex (OR) 运算符的问题
我在我的Laravel规则和正则表达式操作中遇到了一个小问题:
基本上,规则是这样的数组:
'room'=>'required|alpha_num|min:2|max:10',
我遇到的问题是使用正则表达式和|(或)运算符,例如:
'cid'=>'required|regex:/^((comp)|(soen)|(engr)|(elec))\d{3}$/i',
我收到一个服务器错误,说:
ErrorException
preg_match(): No ending delimiter '/' found
我猜是停在里面的第一个.preg_match
|
/.../
无论如何,有没有编写上面的代码来使其工作?
完整代码 :
public static $rules = array(
'cid' => array('required', 'regex:/^((comp)|(soen)|(engr)|(elec))\d{3}$/i'),
'description'=>'required|regex:/^[A-Za-z \t]*$/i|min:3|unique:courses',
'credits'=>'required|regex:/^\d+(\.\d)?$/'
);