def regex(self, protocols, localhost=True):
p = r"<STR_LIT>"<EOL>p += r"<STR_LIT>".format('<STR_LIT:|>'.join(protocols))<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT:|>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>" if not localhost else r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT:)>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT>"<EOL>p += r"<STR_LIT:$>"<EOL>return p<EOL>
URL Validation regex
Based on regular expression by Diego Perini (@dperini) and provided
under MIT License: https://gist.github.com/dperini/729294
:return: