All pastes #182771 Raw Edit

Something

public python v1 · immutable
#182771 ·published 2006-09-26 10:31 UTC
rendered paste body
def truncate_url(url, length=40):	if len(url) <= length:		return url	import re	pattern = r'(/[^/]+/?)$'	match = re.search(pattern, url)	if not match:		return url	l = len(match.group(1))	t_url = url[0:len(url)-l][0:length-3]+"..."+match.group(1)	return t_url