V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
luztak
V2EX  ›  Python

@Livid @whtsky at/email/url的re

  •  
  •   luztak ·
    luztak · 2012-07-03 03:26:13 +08:00 · 2721 次点击
    这是一个创建于 4308 天前的主题,其中的信息可能已经有所发展或是发生改变。
    @Livid @whtsky

    其中,at_user_filter只适合英文数字用户名,可以带"-"和"_".并且可以过滤邮箱地址.
    email_filter中默认添加了几种常用的后缀,一般也只用得到这些后缀.
    url_filter可以解析http/https/ftp协议/无协议字符的地址,支持泛解析域名,后缀懒得限制,如果需要可以自己改.整个地址支持只有域名,域名加斜杠,域名加目录文件名,并且用了unicode,支持中文.
    目前只有at_user_filter是针对从整段文字抽取做过调整的,email和url特征比at_user复杂,不需要限定条件.
    所有代码在 codepad.org 的Python2.5环境下测试通过.测试结果地址见gist中的test_result_urls.
    2 条回复    1970-01-01 08:00:00 +08:00
    luztak
        1
    luztak  
    OP
       2012-07-03 03:26:32 +08:00
    luztak
        2
    luztak  
    OP
       2012-07-03 03:34:22 +08:00
    @Livid email_filter开头那个\w+我在gist改成\w{1,63}了,这边不动……而且个人信息页的GitHub repos列表也是固定的,难道不能走他们的流量?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1629 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 16:46 · PVG 00:46 · LAX 09:46 · JFK 12:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.