我正在寻找Python中的URL正则表达式,在读取堆栈溢出后我决定采用这一个:http://daringfireball.net/2010/07/improved_regex_for_matching_urls并在我的Python代码中使用它。Python的正则表达式错误
我已经把这样的事情:
SyntaxError: Non-ASCII character '
\xe2
' in filefile.py
on line 60, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
的是:
reg_url =
re.compile(r"""((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|(([^\s()<>]+|(([^\s()<>]+)))\*))+(?:(([^\s()<>]+|(([^\s()<>]+)))\*)|[^\s`!()[]{};:`".,<>?«»“”‘’]))""",
re.DOTALL)
(Python 2.7版)
运行我的代码与正则表达式我收到以下错误后解决这个问题的最好方法是什么?
你有卷曲的引号和非ASCII字符:'«»“”'''。阅读PEP。 – Blender