سؤال

I am working on a time regex (24 hours) in laravel, but cant get it working:

'Time' => 'regex:/^\d(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9]$/'
هل كانت مفيدة؟

المحلول

Use something like this:

$rules = array(
    'time' => array('regex:/^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$/')
);

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top