laravel regex validation not working

核能气质少年 提交于 2021-02-06 09:14:40

问题


I've just started using laravel and I'm working on validating a textarea in one of my forms.

The textarea is for the users bio and so I only want to allow letters, numbers, spaces and the following characters: , . ? ; : ' " - () ! / @ $

This is what I have

$validator = Validator::make(Input::all(),
array('bio' => array('regex:[a-zA-Z0-9 ,\.\?;:\'"-\(\)!/@\$]')
    )
);

I've been searching and trying a lot to get it to work but I just can't figure it out.

Any help would be much appreciated.

Thanks


回答1:


Try this:

array('Regex:/^[A-Za-z0-9\-! ,\'\"\/@\.:\(\)]+$/')


来源:https://stackoverflow.com/questions/22430529/laravel-regex-validation-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!