I am trying to setup a site, and want people with only "@gmail.com" should be able to register or buy a product, any help on this would be appreciated.
It works thanks a lot, any case I want to add one more domain along with gmail.com let's say yahoo.co.uk, in that case, can you tell what needs to add? also is the wildcards allowed for example yahoo.*.*?
I figured out how to add multiple domains, thank so much for your support, have a great day ahead.
Hey Kakoli,
Glad I could help, and that's great you found the solution for multiple domains, but it would be more better to share your thoughts and implementation with other community member so in future it will helps other members too!
For any regex expression, you need to understand what does each expression mean.
Let see, your regex is seems like ^[a-zA-Z0-9._%+-]+@(gmail\.com|yahoo\.*.*)$ * Quantifier — Matches between zero and unlimited times, as many times as possible, giving back as needed (greedy) .* matches any character (except for line terminators)
So, if you want to use all domain with yahoo(.com, .au, .uk, .in etc.), I think your regular expression would be ^[a-zA-Z0-9._%+-]+@(gmail\.com|yahoo\.\w+)
I haven't checked with any project but it should work.
Advice: you can use online regex checker https://regex101.com/ before implementation, it will save your time!