/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.regex.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main (String[] args) throws java.lang.Exception
	{
		//String[] URLs = new String[] { "http://f...content-available-to-author-only...o.com/blah_blah", "http://f...content-available-to-author-only...o.com/blah_blah/", "http://f...content-available-to-author-only...o.com/blah_blah_(wikipedia)", "http://f...content-available-to-author-only...o.bar?q=Spaces should be encoded" };
		//String[] URLs = new String[] { "[20:56] <@Котофеич> http://s...content-available-to-author-only...l.com/pics/pics_original/3/4/2/5825243.jpg" }; 
		// The URL above is invalid since it contains consecutive dots
		String[] URLs = new String[] { "[20:56] <@Котофеич> http://s...content-available-to-author-only...l.com/pics/pics_original/3/4/2/5825243.jpg" };
		Pattern REGEX = Pattern.compile("(?i)\\b(?:(?:https?|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?!(?:10|127)(?:\\.\\d{1,3}){3})(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))\\.?)(?::\\d{2,5})?(?:[/?#]\\S*)?\\b");
		for (String url : URLs) {
            Matcher matcher = REGEX.matcher(url);
            if (matcher.find()) {
                System.out.println(matcher.group());
              }
            
        }
            
    }
}