推荐学习书目
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
kenneth
V2EX  ›  Python

菜鸟请教一个Python正则问题

  •  
  •   kenneth · May 23, 2013 · 3481 views
    This topic created in 4763 days ago, the information mentioned may be changed or developed.
    https://gist.github.com/kenneth/5633351

    想去掉content中的ubb,只要链接,应该如何写?

    请高手赐教。
    9 replies    1970-01-01 08:00:00 +08:00
    jason52
        1
    jason52  
       May 23, 2013
    您是想抓图?哪里有ubb呢?
    jason52
        2
    jason52  
       May 23, 2013
    you mean URL?
    dreampuf
        4
    dreampuf  
       May 23, 2013   ❤️ 1
    dreampuf
        5
    dreampuf  
       May 23, 2013
    import re
    re.search("\\[(?:([^=]+)=([^\\]]+)|([^\\]]+))\\]([^\\[]+)\\[/(?:\\1|\\3)\\]", searchText)
    KotiyaSanae
        7
    KotiyaSanae  
       May 23, 2013
    @kenneth 没太看懂你要匹配什么,是所有的boston么?那个网站不太会用……
    pattern = r'.*](http://.*html?).*' ? python环境下通过……
    jason52
        8
    jason52  
       May 23, 2013
    这种事强烈推荐用pyquery做 代码可以很简单 抓图代码就这么一点
    http://dpaste.com/1196576/
    jason52
        9
    jason52  
       May 23, 2013
    @KotiyaSanae 如果用re的话这种可以
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1150 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 17:34 · PVG 01:34 · LAX 10:34 · JFK 13:34
    ♥ Do have faith in what you're doing.