I want to validate an email field using regex in such a way that my email has to has @moore in it. like a@moore.af, b@moore.sg, and so on. how can I write its pattern? I am using typescript and angular reactive form.
Your help is much appreciated.
I want to validate an email field using regex in such a way that my email has to has @moore in it. like a@moore.af, b@moore.sg, and so on. how can I write its pattern? I am using typescript and angular reactive form.
Your help is much appreciated.
You can try to use ([\w-\.]+@moore\.[\w+]{1,5})
to match an email address, as I left a 1-5 characters' space for the domain name.
In JavaScript flavour: const regex = /([\w-\.]+@moore\.[\w+]{1,5})/gm;
then you can use regex.test(str)
to validate the email field.
Edit:
As @Toto pointed out, This regex matches .....@moore.++++
. Better regex would be:
([a-zA-Z0-9\.-]+@moore\.[a-zA-Z0-9\.]{1,5})
to only accept alphabet/number in the domain name.