Laravel5.6 / PHP 7.4.12
正規表現を複数、OR条件で組み合わせたいのですが、
"preg_match(): No ending delimiter '/' found エラーが表示されます。
試したこと
PHP
1class sample_request extends FormRequest { 2 3 public function authorize() 4 { 5 return true; 6 } 7 8 public function rules() 9 { 10 $data = $this->all(); 11 return [ 12 'sample' => 'required|regex:/^[a-zA-Z]+$ | ^(?!.[0-9]).*$/'; 13 ]; 14 } 15~~~ 16 17リクエストクラスの正規表現部抜粋 18'sample' => 'required|regex:/^[a-zA-Z]+$ | ^(?!.[0-9]).*$/'; 19 → preg_match(): No ending delimiter '/' found 20 21単体で確認 22'sample' => 'required|regex:/^[a-zA-Z]+$/'; 23 → 正常に動作 24'sample' => 'required|regex:/^(?!.[0-9]).*$/'; 25 → 正常に動作
regex:のあと全体を()で囲う、など試しましたがpreg_match(): No ending delimiter '/' foundを解消することができずに止まっているところです。
単純な文字だけをはじく'AA|BB|CC'のような複数条件のように書く方法をご教示いただけますと幸いです。
宜しくお願いいたします。
回答1件
あなたの回答
tips
プレビュー