I need to validate the url using regex. The valid formats that should be accepted are as follows:
users.kathir.com www.kathir.com I am currently using the following regex:
^[a-z0-9-]+(\.[a-z0-9-])+(.[a-z]) But it accepts www.google as the valid one, but it should accept either google.com or www.google.com only. Please suggest
.(com|edu)rather than the character class.[a-z]. You should update your question to be very specific about what you want to validate rather than four examples only showing one example of an invalid URL