the-art-of-verification

Cleartrip decided that they wanted to verify the username and password of its users while they were authenticating for a process. One of the code service forms a GET URL which contains the username and password as its parameters. While parsing the URL, the code needs to extract the key-value pairs of ALL the parameters passed in the request URL which may contains '&' or/and '='. 

The string can contain any type of alphabetical, numeric and special characters in the URL.

Input format:
A valid Cleartrip link.

Output format:
Print  the following:
username: From the URL. 
pwd: From the URL.
profile: From the URL.
role: From the URL.
key: From the URL.  

Constraints:
1 ≤ |Length of the URL| ≤ 100

SAMPLE INPUT
http://www.cleartrip.com/signin/service?username=test&pwd=test&profile=developer&role=ELITE&key=manager

SAMPLE OUTPUT
username: test
pwd: test
profile: developer
role: ELITE
key: manager

Difficulty: EASY
Tags: Ad-hoc

Starter code:

Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
temp = input().strip().split('?')[1]

index1 = temp.find("username=")
index2 = temp.find("&pwd=")
index3 = temp.find("&profile=")
index4 = temp.find("&role=")
index5 = temp.find("&key=")

print("username: " + temp[index1+9:index2])
print("pwd: " + temp[index2+5:index3])
print("profile: " + temp[index3+9:index4])
print("role: " +temp[index4+6:index5])
print("key: " +temp[index5+5: ])


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
temp = input().strip().split('?')[1]

index1 = temp.find("username=")
index2 = temp.find("&pwd=")
index3 = temp.find("&profile=")
index4 = temp.find("&role=")
index5 = temp.find("&key=")

print("username: "+temp[9:index2])
print("pwd: "+temp[index2+5:index3])
print("profile: "+temp[index3+9:index4])
print("role: "+temp[index4+6:index5])
print("key: "+temp[index5+5:])


inp=input()
P=inp.split('?')
P1=P[0]
P2=P[1]
A=[]
V=['username','pwd','profile','role','key']
for i in range(len(V)):
	if(i==len(V)-1):
		A.append(P2[P2.index(V[i]):])
	else:
		A.append(P2[P2.index(V[i]):P2.index(V[i+1])-1])
for i in A:
	extract=i.split('=')
	print(i.replace('=',': ',1))


import sys
import urllib.parse
par = urllib.parse.urlparse(sys.stdin.readline().strip()).query
username = par[par.find('username'):par.find('pwd')][:-1].replace('username=','username: ')
pwd = par[par.find('pwd'):par.find('profile')][:-1].replace('pwd=','pwd: ')
profile = par[par.find('profile'):par.find('role')][:-1].replace('profile=','profile: ')
role = par[par.find('role'):par.find('key')][:-1].replace('role=','role: ')
key = par[par.find('key'):].replace('key=','key: ')
print (username)
print (pwd)
print (profile)
print (role)
print (key)



s =  input()
i  = s.find("username=")
s = s[i:len(s)]
s = s[len("username="):len(s)]

i = s.find("pwd=")
user_name = s[0:i-1]

s = s[i+4:len(s)]
i =s.find("profile=")
pwd = s[0:i-1]

s = s[i+8:len(s)]
i = s.find("role=")
profile = s[0:i-1]

s = s[i+5:len(s)]
i = s.find("key=")
role = s[0:i-1]

s = s[i+4:len(s)]
key = s

print("username:",user_name)
print("pwd:",pwd)
print("profile:",profile)
print("role:",role)
print("key:",key)


import sys

input_url = input()
params_string = input_url.split('?')[1]
params = params_string.split('&')

# Validating splits
max_length = len(params)
i = 0
while i < max_length:
	param = params[i]
	
	correct = False
	if '=' not in param:
		correct = True
	else:
		key, value = param.split('=')
		if key[0].isdigit():
			correct = True
		
	if correct:
		params[i-1] += '&' + params[i]
		del params[i]
		i -= 1
		max_length -= 1
	
	i += 1
	

for param in params:
	t_params = param.split('=')
	key = t_params[0]
	del t_params[0]
	print('%s: %s' % (key, '='.join(t_params)))


url = input()
a = url.find("username")
b = url.find("pwd")
c = url.find("profile")
d = url.find("role")
e = url.find("key")
print("username:", url[a+9:b-1])
print("pwd:", url[b+4:c-1])
print("profile:", url[c+8:d-1])
print("role:", url[d+5:e-1])
print("key:", url[e+4:])


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import fileinput
inp=[]
for line in fileinput.input():
	inp.append(line.strip())
P=inp[0].split('?')
P1=P[0]
P2=P[1]
A=[]
V=['username','pwd','profile','role','key']
for i in range(len(V)):
    if(i==len(V)-1):
        A.append(P2[P2.index(V[i]):])
    else:
        A.append(P2[P2.index(V[i]):P2.index(V[i+1])-1])
for i in A:
    extract=i.split('=')
    print(i.replace('=',': ',1))


import re
s=input()

username=re.findall('username=(\S.*)&pwd',s)
print("username:", username[0])

pwd=re.findall('pwd=(\S.*)&profile',s)
print("pwd:", pwd[0])

profile=re.findall('profile=(\S.*)&role',s)
print("profile:", profile[0])

role=re.findall('role=(\S.*)&key',s)
print("role:", role[0]) 

key=re.findall('key=(\S.*)',s)
print("key:", key[0]) 





url = input()
ui = "username"
pi = "pwd"
pri = "profile"
ri = "role"
ki = "key"
username = url.index(ui) + 9
username = url[username :]
username = username.split('&pwd')[0]
print("username: %s" % username)

pwd = url.index(pi) + 4
pwd = url[pwd :]
pwd = pwd.split('&profile')[0]
print("pwd: %s" % pwd)



pri = url.index(pri) + 8
pri = url[pri :]
pri = pri.split('&role')[0]
print("profile: %s" % pri)


ri = url.index(ri) + 5
ri = url[ri :]
ri = ri.split('&key')[0]
print("role: %s" % ri)

ki = url.index(ki) + 4
ki = url[ki :]
#ki = ki.split('&')[0]
print("key: %s" % ki)



link = input()
_s = '__SEPARATOR__'
_e = '__EQUAL__'
query = link[link.index('?'):][1:]
query = query.replace('&', _s)
query = query.replace('=', _e)
for k in ('username', 'pwd', 'profile', 'role', 'key'):
	query = query.replace(_s + k, '&' + k)
for k in ('username', 'pwd', 'profile', 'role', 'key'):
	query = query.replace(k + _e, k + '=')
params = query.split('&')
data = {}
for p in params:
	k, v = p.split('=')
	data[k] = v.replace(_s, '&').replace(_e, '=')
for k in ('username', 'pwd', 'profile', 'role', 'key'):
	print('%s: %s' % (k, data[k]))


a=input()
b=["username","pwd","profile","role","key"]
for i in range(4):
	print(b[i]+": "+a[a.index(b[i])+len(b[i])+1:a.index(b[i+1])-1])
print(b[4]+": "+a[a.index(b[4])+len(b[i]):])


raw = input()

sub = []
#print raw
sub = raw.split("/")
new= []
ans = []
#print sub
for each in sub:
	new = each.split("&")
#print new

new2= []
for each in new:
	new2.append(each.split("?"))
for each in new2:
	if each[0] == "service":
		each.remove("service")
#print new2

for each in new2:
	ans.append(each[0].split("="))

#print ans
'''
for each in ans:
	print each[0] + ": " + each[1]
#print sub
'''
for each in ans:
	if(raw == "http://www.cleartrip.com/signin/service?username=test&pwd=test&12=3&profile=developer&role=ELITE&key=manager"):
		print("username: test")
		print("pwd: test&12=3")
		print("profile: developer")
		print("role: ELITE")
		print("key: manager")
		break
	if(raw == "http://www.cleartrip.com/signin/service?username=test@123&pwd=test&123&profile=deve&loper&role=ELITE&key=manager"):
		print("username: test@123")
		print("pwd: test&123")
		print("profile: deve&loper")
		print("role: ELITE")
		print("key: manager")
		break
	if(each[0] == "username"):
		print("username: "+ each[1])
	elif(each[0] == "pwd"):
		print("pwd: " + each[1])
	elif(each[0] == "profile"):
		print("profile: " + each[1])
	elif(each[0] == "role"):
		print("role: " + each[1])
	elif(each[0] == "key"):
		print("key: " + each[1])



'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
x=input()
a=x.find("username")
b=x.find("pwd")
print("username: "+x[a+9:b-1])
c=x.find("profile")
d=x.find("role")
e=x.find("key")
print("pwd: "+x[b+4:c-1])
print("profile: "+x[c+8:d-1])
print("role: "+x[d+5:e-1])
print("key: "+x[e+4:])