#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cctype>
usingstd::cout;
usingstd::cin;
usingstd::endl;
usingstd::vector;
usingstd::string;
usingstd::find_if; // #include<algorithm>, 범위내에서 세번째 인자로 모든 요소들에 대해 동작하는 함수를
// 호출하며 동작 함수가 true의 결과는 내는 요소를 찾아 멈춘다.
usingstd::find; // #include<algorithm>, 범위내에서 세번째 인자로 얻어진 특정 값을 검색
usingstd::isalnum; // #include<cctype>, 인자가 알파벳이나 숫자문자인지를 검사
usingstd::isalpha; // #include<cctype>, 인자가 영문자인지 검사
bool not_url_char(char c)
{
// 알파벳 및 숫자 외에 URL에 포함될 수 있는 상수 정의
staticconststring url_ch = "~;/?:@=&$?.+!*?(),-_";
// c가 영문자,숫자, 또는 url_ch의 문자인 경우에 false를 리턴
return !(isalnum(c) || find(url_ch.begin(), url_ch.end(), c) != url_ch.end());
}
string::const_iterator url_beg(string::const_iterator b, string::const_iterator e)
{
staticconststring sep="://";
typedefstring::const_iterator iter;
iter i=b;
while((i=search(i,e,sep.begin(),sep.end())) != e)
{
// 식별자가 라인의 시작이나 끝에 있는지 검사
if(i != b && i+sep.size() !=e)
{
// beg는 protocol-name의 시작을 표시
iter beg=i;
// 컨테이너가 인덱싱을 지원하면, 반복자도 인덱싱 지원한다. beg[-1] == *(beg-1)
while(beg != b && isalpha(beg[-1]))
--beg;
// 식별자의 앞과 뒤에 최소 하나의 적절한 문자가 포함되어 있는지 검사
if(beg != i && !not_url_char(i[sep.size()]))
return beg;
}
// URL에 해당하지 않은 경우에 다음 식별자를 검사하도록 함
i += sep.size();
}
return e;
}
string::const_iterator url_end(string::const_iterator b, string::const_iterator e)
{
return find_if(b, e, not_url_char);
}
vector<string> find_urls(conststring &s)
{
vector<string> ret;
typedefstring::const_iterator iter;
iter b=s.begin(), e=s.end();
while(b!=e)
{
// 식별자 :// 앞과 뒤에 하나 이상의 문자가 있는지 검사
b = url_beg(b, e);
// 만약 찾았다면
if(b!=e)
{
// URL의 :// 나머지 뒷부분을 확인
iter after = url_end(b, e);
// URL 기억
ret.push_back(string(b, after));
//b가 다음 URL를 찾도록 증가
b=after;
}
}
return ret;
}
int main()
{
string str;
vector<string>::const_iterator iter;
while(getline(cin,str))
{
vector<string> temp = find_urls(str);
for(iter=temp.begin(); iter!=temp.end(); ++iter)
{
cout<<(*iter)<<endl;
}
}
return0;
}