Regular expression for checking valid and invalid TLDs

^\w+(\.\w+)*$

Demo at http://regexr.com/38p7n

Valid entries

  • com
  • co.in
  • abc.abc
  • abc.edu.acb.acse.cse

Invalid entries

  • .com
  • com..com
  • .co.in