Write a function that when given a URL as a string, parses out just the domain name and returns it as a string. For example:
```python
domain_name("http://github.com/carbonfive/raygun") == "github" 
domain_name("http://www.zombie-bites.com") == "zombie-bites"
domain_name("https://www.cnet.com") == "cnet"
```

Source: codewars | Difficulty: EASY

Starter code: def domain_name(url):
	

Solutions:
def domain_name(url):
	return url.split('//')[-1].split('www.')[-1].split('.')[0]


import re

def domain_name(url):
	return re.search('(https?://)?(www\\d?\\.)?(?P<name>[\\w-]+)\\.', url).group('name')


def domain_name(url):
	url = url.replace('www.', '')
	url = url.replace('https://', '')
	url = url.replace('http://', '')
	return url[0:url.find('.')]


def domain_name(url):
	a = url.replace('http:', ' ').replace('https:', ' ').replace('/', ' ').replace('//', ' ').replace('.', ' ').replace('www', ' ').split()
	return a[0]


def domain_name(url):
	print(url)
	url = url.replace('http://', '')
	url = url.replace('https://', '')
	url = url.replace('www.', '')
	end = url.find('.')
	return url[0:end]


def domain_name(url):
	if 'www.' in url:
		x = url.split('www.')
		url = x[1]
	if '://' in url:
		x = url.split('://')
		url = x[1]
	if '.' in url:
		x = url.split('.')
		x = x[0]
	return x


import re

def domain_name(url):
	return re.search('(https?:\\/\\/)?(www\\d?\\.)?([\\w-]+)\\.', url).group(3)


def domain_name(url):
	url = url.replace('http://www.', '')
	url = url.replace('www.', '')
	url = url.replace('https://', '')
	url = url.replace('http://', '')
	return url[:url.index('.')]


import re

def domain_name(url):
	return re.search('(/{2})?(www\\.)?(?P<name>[\\w-]+)[.?]', url).group('name')


from urllib.parse import urlparse

def domain_name(url):
	parsed = urlparse(url)
	dom = parsed.netloc
	path = parsed.path
	if dom:
		dom_spl = dom.split('.')
		if dom_spl[0] == 'www':
			return dom_spl[1]
		return dom_spl[0]
	elif path:
		path_spl = path.split('.')
		if path_spl[0] == 'www':
			return path_spl[1]
		return path_spl[0]


from re import compile, match
REGEX = compile('(http[s]*://)?(www.)?(?P<domain>[\\w-]+)\\.')

def domain_name(url):
	return match(REGEX, url).group('domain')


def domain_name(url):
	if '//' in url:
		list1 = url.split('//')
	if 'www.' in url:
		list1 = url.split('www.')
	try:
		str1 = list1[1]
		list2 = str1.split('.')
		return list2[0]
	except:
		list2 = url.split('.')
		return list2[0]


import re

def domain_name(url):
	if 'www' in url:
		url = url.replace('www.', '')
	regex1 = '\\/\\/[^.]+'
	regex2 = '[^.]+'
	if url.startswith('http'):
		domain = re.findall(regex1, url)
	else:
		domain = re.findall(regex2, url)
	if '//' in domain[0]:
		return domain[0][2:]
	else:
		return domain[0]


import re

def domain_name(url):
	return re.search('(?:https?://)?(?:w{3}\\.)?(.*?)\\..*', url).group(1)


domain_name = lambda url: url.replace('http://', '').replace('www.', '').replace('https://', '').replace('.', ' ').split()[0]


import re

def domain_name(url):
	if url.find('://') == -1:
		url += '://' + url
	return re.findall('.*\\://(?:www.)?([^\\/]+)', url)[0].partition('.')[0]


import re

def domain_name(url):
	print(url)
	ur = '(?:https?://www\\.|www\\.|https://www\\.|https?://|)(.+?)\\.'
	a = re.findall(ur, url)
	if len(a) == 0:
		return ''
	return a[0]


def domain_name(url):
	domain = url.replace('http://', '').replace('www.', '').replace('https://', '')
	domain1 = domain.split('.')
	return ''.join(domain1[0])


import re

def domain_name(url):
	return re.sub('(http(s)?:\\/\\/)?(www\\.)?', '', url).split('.')[0]


import re

def domain_name(url):
	return re.match('(?:https?\\://)?(?:www.)?([a-z0-9-]*)\\.*', url).group(1)


import re

def domain_name(url):
	url_pattern = re.compile('^(https?://(www.)?|(www.))?([^.]+)\\..*$')
	return url_pattern.sub('\\4', url)


import re

def domain_name(url):
	pattern = '^(https?://(www.)?|(www.))?([^.]+)\\..*$'
	return re.sub(pattern, '\\4', url)


import re

def domain_name(url):
	r = re.sub('www\\.', '', url)
	r = re.search('[\\w\\-]{3,}\\.\\w{2,3}', r)
	r = re.search('[\\w\\-]+', r[0])
	return r[0]


import re

def domain_name(url):
	domain = re.sub('(http[s]?://)?(www\\.)?([^\\.]+)(.*)', '\\g<3>', url)
	return domain


import re

def domain_name(url):
	return re.findall('(?:http[s]?://)?(?:www\\.)?([0-9a-zA-Z\\-]+)\\..*', url)[0]


def domain_name(url):
	if 'www.' in url:
		url = url.split('www.')[-1]
	elif '//' in url:
		url = url.split('//')[-1]
	return url.split('.')[0]


from urllib.parse import urlparse

def domain_name(url):
	if not (url.startswith('https://') or url.startswith('http://')):
		url = 'http://' + url
	return urlparse(url).hostname.replace('www.', '').split('.')[0]


import re

def domain_name(url):
	pattern = '[\\-\\.a-z0-9]+|www.[\\-a-z0-9]+\\.'
	string = re.findall(pattern, url)
	string = string[1 if len(string) > 1 and 'http' in string[0] else 0]
	return re.sub('www\\.|\\/\\/|\\.[\\.a-z]+$|\\.', '', string)


from re import sub

def domain_name(url):
	return sub('^(?:https?:\\/\\/)?(?:www\\.)?([\\w\\-]+)\\.(?:.*?)$', '\\1', url)


def domain_name(url):
	d = url.split('//')
	try:
		f = d[1].split('.')
	except IndexError:
		f = d[0].split('.')
	return f[0] if f[0] != 'www' else f[1]


def domain_name(url):
	napis = url
	if '//' in napis:
		tab = napis.split('//')
		czlon = tab[1]
		print(czlon[0])
	else:
		czlon = napis
	if not czlon.startswith('www'):
		zmienna = czlon.split('.')
		print(zmienna[0])
		wynik = zmienna[0]
	else:
		zmienna = czlon.split('.')
		print(zmienna[1])
		wynik = zmienna[1]
	return wynik


def domain_name(url):
	filter_list = ['http://', 'www.', 'https://']
	for f in filter_list:
		if f in url:
			url = url.replace(f, '')
	new_url = url.split('.')
	return new_url[0]


def domain_name(url):
	print(url)
	if '//' in url:
		url = url.split('//', 1)[1]
	if 'www.' in url:
		url = url.split('www.', 1)[1]
	return url.split('.', 1)[0]


def domain_name(url):
	url = url.replace('http://www.', '')
	url = url.replace('https://', '')
	url = url.replace('http://', '')
	url = url.replace('www.', '')
	a = ''
	for i in url:
		if i != '.':
			a = a + i
		else:
			return a


def domain_name(url):
	if 'w' * 3 in url:
		new_url = url[url.index('.') + 1:]
		return new_url[:new_url.index('.')]
	elif '/' * 2 in url:
		return url[url.index('/') + 2:url.index('.')]
	else:
		return url[:url.index('.')]


def domain_name(url):
	if url.startswith('http'):
		url = url.split('//')[1]
	if url.startswith('www'):
		return url.split('.')[1]
	return url.split('.')[0]


import re

def domain_name(url):
	return re.sub('/[a-z]*/?', '', re.sub('\\.[a-z]*', '', re.sub('(https?|www)(://|\\.)', '', url)))


def domain_name(url):
	url = url.replace('www.', '').replace('https://', '').replace('http://', '')
	index = url.find('.')
	return url[0:index]
	pass


def domain_name(url):
	if url[0:8] == 'https://' or url[0:7] == 'http://':
		if url[8:12] == 'www.' or url[7:11] == 'www.':
			return url.partition('.')[2].partition('.')[0]
		else:
			return url.partition('//')[2].partition('.')[0]
	elif url[0:4] == 'www.':
		return url.partition('.')[2].partition('.')[0]
	else:
		return url.partition('.')[0]


import re

def domain_name(url):
	url = re.sub('(https:\\/\\/www\\.|http:\\/\\/www\\.|https:\\/\\/|http:\\/\\/|www\\.)', '', url)
	return re.sub('\\..+', '', url)


def domain_name(url):
	if 'www.' in url:
		startpos = url.find('www.') + 4
	elif '://' in url:
		startpos = url.find('://') + 3
	else:
		startpos = 0
	endpos = url.find('.', startpos)
	return url[startpos:endpos]


from urllib.parse import urlparse

def domain_name(url):
	url = url.replace('www.', '')
	url = url.replace('http://', '')
	url = url.replace('https://', '')
	domain_name = url.split('.')[0]
	return domain_name


def domain_name(url):
	url = url.replace('www.', '').split('/')
	for i in url:
		if '.' in i:
			url = i
			break
	(domain, mid, tail) = url.partition('.')
	return domain


def domain_name(url):
	url = url.replace('http://', '')
	url = url.replace('https://', '')
	url = url.replace('www.', '')
	last = url.rfind('/')
	if last is not None:
		url = url[:last]
	dot = url.find('.')
	if dot is not None:
		url = url[:dot]
	return url


def domain_name(url):
	if url.startswith('htt'):
		removehttp = url.split('//')
		if removehttp[1].startswith('w'):
			removewww = removehttp[1].split('www.')
			solution = removewww[1].split('.')
			return solution[0]
		else:
			solution = removehttp[1].split('.')
			return solution[0]
	elif url.startswith('w'):
		removewww = url.split('www.')
		solution = removewww[1].split('.')
		return solution[0]
	else:
		solution = url.split('.')
		return solution[0]


def domain_name(url):
	print(url)
	start = url[0:3]
	print(start)
	http = 'htt'
	www = 'www'
	start2 = url[0:10]
	http2 = 'http://www'
	if start == http and start2 != http2:
		split_list = url.split('//')
		return split_list[1].split('.')[0]
	elif start == www:
		return url.split('.')[1]
	elif start2 == http2:
		return url.split('.')[1]
	else:
		return url.split('.')[0]


def domain_name(url):
	for i in ['https://', 'http://', 'www.', '.com', '.in']:
		url = url.replace(i, '')
	return url.replace('.', '/').split('/')[0]


import regex as re

def domain_name(url):
	return re.sub('(https?:\\/\\/|www\\.)*([^.]*)\\..*', '\\2', url)


import re

def domain_name(url):
	url = url.replace('https://', '').replace('http://', '').replace('www.', '')
	print(re.findall('^[^\\.]+', url))
	return re.findall('^[^\\.]+', url)[0]


import re

def domain_name(url):
	pat = '(http[s]?://)*(www\\.)*(\\w+[-_]*\\w+)\\b(\\..*)'
	res = re.match(pat, url)
	return str(res.group(3))


def domain_name(url):
	print(url)
	split = url.split('.')
	if split[0] == 'www':
		return split[1]
	elif 'http://www' in split[0] or 'https://www' in split[0]:
		return split[1]
	elif 'http' in split[0] or 'https' in split[0]:
		split = split[0].split('//')
		return split[1]
	else:
		return split[0]


def domain_name(url):
	if url[:4] == 'http' or url[:4] == 'www.':
		url = url[4:]
		if url[0] == 's':
			url = url[1:]
	if url[:3] == '://':
		url = url[3:]
	if url[:4] == 'www.':
		url = url[4:]
	dot = url.index('.')
	url = url[:dot]
	return url


import re

def domain_name(url):
	return [m for m in re.findall('[(\\w+)(?=\\-)]+(?=\\.)', url) if m != 'www'][0]


def domain_name(url):
	parts = url.split('//')
	portion = parts[0]
	if len(parts) > 1:
		portion = parts[1]
	if 'www' in portion:
		return portion.split('.')[1]
	return portion.split('.')[0]


import re

def domain_name(url):
	if 'www.' not in url:
		if '://' in url:
			m = re.search('(?<=//)\\S+?(?=\\.)', url)
		else:
			m = re.search('\\S+?(?=\\.)', url)
	else:
		m = re.search('(?<=\\.)\\S+?(?=\\.)', url)
	return m.group(0)


def domain_name(url):
	return url.split('//')[-1].split('.')[1] if 'www' in url else url.split('//')[-1].split('.')[0]


def domain_name(url):
	if 'www.' in url:
		return url.split('.')[1].split('.')[0]
	elif '.' and '//' in url:
		return url.split('//')[1].split('.')[0]
	else:
		return url.split('.')[0]


def domain_name(url):
	if url[0:4] == 'http':
		url = url[url.find('//') + 2:-1]
	url = url.split('.')
	return url[0] if url[0] != 'www' else url[1]


import re
regex_pattern = '(https?:\\/\\/)?[w]{0,3}\\.?([A-Z,a-z,0-9,-]*).*'

def domain_name(url):
	print(url)
	return re.search(regex_pattern, url).group(2)


import re
domain_name = lambda url: re.search('^(https?\\:\\/\\/)?(www.)?([a-zA-Z0-9\\-]+)', url).group(3)


def domain_name(url):
	print(url)
	if 'www.' in url:
		s = url.find('www.') + 4
	elif '//' in url:
		s = url.find('//') + 2
	else:
		s = 0
	e = url.find('.', s)
	return url[s:e]


import re

def domain_name(url):
	g = re.sub('((http|https)\\:\\/\\/)?(www.)?', '', url)
	s = re.search('[a-zA-Z0-9-]*.', g)
	return s.group()[:-1]


import re

def domain_name(url):
	return re.compile('(https:|http:)?(//)?(www.)?([\\w+-]+)').match(url).group(4)


def domain_name(url):
	import re
	result = re.sub('^.*//|www\\.', '', url)
	result = re.sub('\\..*', '', result)
	return result


def domain_name(url):
	domain = ''
	adding = False
	if 'www' in url:
		for char in url:
			if char == '.':
				adding = not adding
				if not adding:
					break
			if adding:
				domain += char
	elif url[6] == '/':
		for char in url:
			if char == '/':
				adding = True
			elif char == '.':
				adding = False
				break
			if adding:
				domain += char
	else:
		adding = True
		for char in url:
			if char == '.':
				adding = False
				break
			if adding:
				domain += char
	domain_arr = list(domain)
	if '/' in domain_arr:
		domain_arr.remove('/')
	if '/' in domain_arr:
		domain_arr.remove('/')
	if '.' in domain_arr:
		domain_arr.remove('.')
	print(url)
	return ''.join(domain_arr)


def domain_name(url):
	print(url)
	first = ''
	second = ''
	if 'www' in url:
		first = url.split('www.')[1]
		second = first.split('.')[0]
	elif 'http' in url:
		first = url.split('://')[1]
		second = first.split('.')[0]
	else:
		second = url.split('.')[0]
	return second


def domain_name(url):
	domain = ''
	if url.startswith('http'):
		url = url[url.find('//') + 2:]
	if url.startswith('www.'):
		domain = url[4:][:url[4:].find('.')]
	else:
		domain = url[:url.find('.')]
	return domain