{"id":20202,"date":"2020-12-29T10:40:10","date_gmt":"2020-12-29T10:40:10","guid":{"rendered":"http:\/\/www.devopsschool.com\/blog\/?p=20202"},"modified":"2020-12-29T11:03:34","modified_gmt":"2020-12-29T11:03:34","slug":"errorexception-preg_match-no-ending-delimiter-found","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/errorexception-preg_match-no-ending-delimiter-found\/","title":{"rendered":"[SOLVED] ErrorException preg_match(): No ending delimiter &#8216;\/&#8217; found"},"content":{"rendered":"<p>I&#8217;m working on Laravel 5.8. I&#8217;m trying to use Validator to validate a name field with regex, here is my rule below:<\/p>\n<p>&nbsp;<\/p>\n<p>But as soon as I call the rule to be validated an error is thrown, see below:<br \/>\n<strong>preg_match(): No ending delimiter &#8216;\/&#8217; found<\/strong><\/p>\n<h2 style=\"text-align: center;\"><strong>Solution<\/strong><\/h2>\n<p>Since regex has a pipe in it, So, we have to use an array:<\/p>\n<p><code>$validated = $request-&gt;validate([<br \/>\n'url' =&gt; ['required', 'regex:\/^(?:https?:\\\/\\\/)?(?:www\\.)?(?:youtu\\.be\\\/|youtube\\.com\\\/(?:embed\\\/|v\\\/|watch\\?v=|watch\\?.+&amp;v=))((\\w|-){11})(?:\\S+)?$\/'],<br \/>\n]);<\/code><\/p>\n<p>From the docs: <a href=\"http:\/\/laravel.com\/docs\/5.1\/validation#rule-regex\" target=\"_blank\" rel=\"nofollow noopener\">http:\/\/laravel.com\/docs\/5.1\/validation#rule-regex<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on Laravel 5.8. I&#8217;m trying to use Validator to validate a name field with regex, here is my rule below: &nbsp; But as soon as I call the&#8230; <\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[5201],"tags":[],"class_list":["post-20202","post","type-post","status-publish","format-standard","hentry","category-laravel"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/20202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=20202"}],"version-history":[{"count":6,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/20202\/revisions"}],"predecessor-version":[{"id":20209,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/20202\/revisions\/20209"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=20202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=20202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=20202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}