Q: laravel regex : 00am-00am I am working on laravel 5.2 and I need to validate a feild (time_slot).
Schema::create('booking', function (Blueprint $table) {
       /// other feilds
        $table->string('time_slot');
       /// other feilds
    });

And in Request I have declared rules to validate it.
    public function rules()
{
    $rules = [
          //other rules
        'time_slot' => 'required|Regex:/^[0-9am-pm\-]+$/',
    ];
    return $rules;
}

I'm looking for a regular expressions that will only accepts values like given below:
[digit][digit][am or pm]-[digit][digit][am or pm]

example 10pm-11pm.. the combination of two digits must be in the range given below.
[00,01,02,03,04,05,06,07,08,09,10,11,12]

Need help to create this kind of RegeX..
Thank !

A: Keeping in mind that hours cannot exceed 12.
Regex: ^([0][0-9]|[1][012])(am|pm)-([0][0-9]|[1][012])(am|pm)$
Regex101 Demo

A: Check this regex
$rules = [
    'time_slot' => 'required|Regex:/([0-9]{2})(am|pm)-([0-9]{2})(am|pm)/',
];

