Laravel-使用正则表达式仅验证字母,数字和空格 [英] Laravel - Validate only letters, numbers and spaces using regex
本文介绍了Laravel-使用正则表达式仅验证字母,数字和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试以这种方式验证由字母,数字和空格组成的字段:
I am trying to validate a field made up of letters, numbers and spaces in this way:
$rules = array(
'field'=> 'regex:/([A-Za-z0-9 ])+/'
);
但是如果我尝试插入''和其他字符,验证仍然必须成功.
but if I try to insert characters like ' " and others, the validation still has to be successful.
我的正则表达式怎么了?
What's wrong 'in my regular expression?
推荐答案
$rules = array(
'field'=> 'regex:/(^[A-Za-z0-9 ]+$)+/'
);
这篇关于Laravel-使用正则表达式仅验证字母,数字和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文