You can use the built-in validation in the Form component.
Each control can have an array of validation rules.
You can have a validation rule with a regex pattern.
Here is a link for a quick demo with your desired behaviour: https://codepen.io/svetoslavb04/pen/YzLVjbN?editors=0010
If you have any further questions, do not hesitate to contact us!