Often I need to extract urls from text file and I hate doing this manually. I know there are library functions which can do this, but not all url is useful for me. Only those urls which satisfy following conditions are important for me.
Syntax of urls is scheme://sub-domain.top-level-domain/path?query_string
com, in, org, gov, uk, pk, etc are called top level domain, everything else is sub domain.
1. Only http or https scheme is allowed.
2. Top level domain as well as sub domain should be of at least 2 chars.
3. Top level domain can contain only letters
4. Sub domain can contain letters, numbers and -
5. Sub domain cannot start or end with -
6. Domain part of link cannot contain consecutive '.' (dot)
7. Path can contain letters, numbers, '+', '&', '#', '\', '/', '%', '?', '=', '_', '.' and '-'
8. Query String can contain letters, numbers, '+', '&', '?', '#', '\', '/', '?' and '-'
NOTE : I don't like very large code so I have set the maximum file size to 500 bytes :P.
You have to read till EOF.
Each line contains a test case.
A test case can contain several urls.
For each test case print all valid urls on seprate line.
After each test case print a blank line.
0 <= length of test case <= 500
Valid Links : Google ( http://www.google.com/ ), Facebook ( https://www.facebook.com/ )
Invalid Links : http://ww.-ww.ww/ http://ww.ww-.ww/ http://www.google.c/
Problem Setter : Pushkar Anand
Problem Tester : Dhruva Bhaswar