朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

TP5验证器填写正则表达式报错preg_match: No ending delimiter ‘/’ found解决办法

错误写法:

$validate = new Validate([
	'password|密码' => '/(^$)|(.+){6,16}$/',
	'repass|确认密码' => '/(^$)|(.+){6,16}$/',
	'tel|手机号' => 'require|/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/'
]);

以前一直都是这么写的, 这次就报错了…不知道为啥

正确写法:

$param = request()->post();

$validate = new Validate([
	'password|密码' => ['regex:/(^$)|(.+){6,16}$/'],
	'repass|确认密码' => ['regex:/(^$)|(.+){6,16}$/'],
	'tel|手机号' => ['require','regex:/^[1](([3][0-9])|([4][5-9])|([5][0-3,5-9])|([6][5,6])|([7][0-8])|([8][0-9])|([9][1,8,9]))[0-9]{8}$/']
]);

if (!$validate->check($param)) {
	return json(['code' => 0, 'msg' => $validate->getError()]);
}

记录一下.
-End-

文章来源于互联网:TP5验证器填写正则表达式报错preg_match: No ending delimiter ‘/’ found解决办法

赞(0) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » TP5验证器填写正则表达式报错preg_match: No ending delimiter ‘/’ found解决办法

评论 26

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #30

    Hey there! Someone in my Facebook group shared this site with us so
    I came to check it out. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers!
    Great blog and amazing design.

  2. #29

    It’s an amazing post in support of all the web visitors; they will get advantage from
    it I am sure.

  3. #28

    Hurrah! In the end I got a weblog from where I be
    capable of actually obtain useful data regarding my study and knowledge.

  4. #27

    What’s up to all, the contents existing at this web page are
    in fact awesome for people experience, well, keep up the nice work fellows.

  5. #26

    I loved as much as you’ll receive carried out right here.
    The sketch is attractive, your authored material
    stylish. nonetheless, you command get bought an edginess over that you wish be delivering the following.
    unwell unquestionably come further formerly again as exactly the same nearly a lot often inside case
    you shield this hike.

    tinyurl.com1周前 (08-04)回复
  6. #25

    Hello every one, here every person is sharing these experience, therefore it’s pleasant to
    read this blog, and I used to pay a quick visit this
    webpage daily.

    tinyurl.com2周前 (07-26)回复
  7. #24

    Wonderful post! We will be linking to this great article
    on our website. Keep up the good writing.

    t.co3周前 (07-22)回复
  8. #23

    Asking questions are really nice thing if you are not understanding
    anything completely, however this paragraph offers nice understanding
    even.

    tinyurl.com4周前 (07-15)回复
  9. #22

    This info is worth everyone’s attention. Where can I find out more?

    http://tinyurl.com1个月前 (07-07)回复
  10. #21

    Excellent blog post. I definitely love this website. Thanks!

    tinyurl.com2个月前 (06-08)回复
  11. #20

    bookmarked!!, I like your web site!

    http://tinyurl.com2个月前 (06-06)回复