I have to validate an input in html using pattern in angular 4 my pattern is
pat = /^(\s*#?\d{1,2}:\d{1,2}\s*(am|pm|AM|PM)\s*,?)+/;
and in html
<input type="text" [pattern]="precisionTimePattern" #precisionSlotValue="ngModel" name="slot-value-precision"
id="slotValuePrecision" class="input-minimal"
[ngModel]="formObject.precisionType.slotValue"
[class.invalid]="(!precisionSlotValue.valid && precisionSlotValue.touched) || (!precisionSlotValue.valid && f.submitted)">
to match string only if "12:00 AM, 2:0 PM #3:00 PM"
but it also validate if user input "12:00 AM, 2:0 PM #3:00 PM ajkcsbkajk"