Laravel Preg_Match(): No Ending Delimiter '/' Found

Laravel preg_match(): No ending delimiter '/' found

Since your regex has a pipe in it, you have to use an array:

public static $rules_save = [
'class_subjects' => ['required', 'regex:/[0-9]([0-9]|-(?!-))+/'],
];

From the docs:

When using the regex pattern, it may be necessary to specify rules in an array instead of using pipe delimiters, especially if the regular expression contains a pipe character.

preg_match(): No ending delimiter '/'

I think you are missing syntax here.You can use below pattern for your regular expression.

array('phone' => 'required', 'required|regex:/^\+?[^a-zA-Z]{5,}$/');

preg_match(): No ending delimiter '/' found Laravel

In Laravel you have ip validation rule so you can use:

    return [            
'segmentwan' => 'ip',
'segmentlan' => 'ip',
];

Also to be honest when I'm looking at your code I don't see the error. Are you sure error is with those 2 regexes?

Laravel time 24h format regex error (No ending delimiter)

Your rule is well done BUT you need to know, specify validation rules with regex separated by pipeline can lead to undesired behavior.

The proper way to define a validation rule should be:

'title' => 'required|max:100|regex:/^(?=.*[a-zA-Z]).+$/',
'start_time' => ['date_format:H:i','regex:/^((([01]?[0-9]|2[0-3]):[0-5][0-9])?)$/'],

You can read on the official docs:

regex:pattern

The field under validation must match the given regular expression.

Note: When using the regex pattern, it may be necessary to specify rules in an array instead of using pipe delimiters, especially if the regular expression contains a pipe character.

https://laravel.com/docs/5.6/validation#rule-regex

PHP regular expressions: No ending delimiter '^' found in

PHP regex strings need delimiters. Try:

$numpattern="/^([0-9]+)$/";

Also, note that you have a lower case o, not a zero. In addition, if you're just validating, you don't need the capturing group, and can simplify the regex to /^\d+$/.

Example: http://ideone.com/Ec3zh

See also: PHP - Delimiters



Related Topics



Leave a reply



Submit