Pregunta

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]$/'
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top