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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!