Question
Write a regex (Example: [Hh]ello means Hello or hello) that could recognize any web page address (URL). Requirements: 1. http://, or https://, is optional, and
Write a regex (Example: [Hh]ello means Hello or hello) that could recognize any web page address (URL).
Requirements:
1. "http://", or "https://", is optional, and one of them may appear once, or not.
2. there is no need for a web page address to have "www"
3. the top level domain must be one of the available domains: "com", "org", "net", or "edu"
4. at least one word (word = at least 2 characters) must be at the front of the top level domain name, and they must be separated by "."
For instance, "ab.com", "ab.cd.efg.com", or "https://ab.com", or "abc.org", etc., they are all valid, but "a.com" is not valid
5. After the top level domain name, there may be zero, one, or more subcategories specified. If there is one subcategory, then symbol "/" must be used to separate it with the top level domain name or other subcategories.
For instance, "ab.com/xyz", "abc.def.net/xyz/xxx", "abc.edu/aaa/bbb.html", etc., are all valid
6. a web page address may end with symbol "/". That is, "abc.com", "abc.com/", or "abc.com/xyz/" are all valid.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started