how to build a regular expression in javascript for com, com.* , co ,co.*

69 Views Asked by At

I would appreciate if anyone can help to build a regular expression for the below scenario,

I am trying to validate these generics (com, co, com.in) for yahoo domain in javascript. Example: yahoo.com , yahoo.co.in are valid. where as yahoo.com.123 , yahoo.co.abc , yahoo.com.abc , yahoo.com.$%^ are invalid.

Allow only 2 characters after com. or co. , do not allow numbers or special symbols after com. or co.

Please suggest if any better ways to validate these in javascript using regular expressions.

Appreciate your time. Thank you

0

There are 0 best solutions below