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

match.group() 也包含非捕获组吗?

  •  
  •   yakczh · Aug 10, 2013 · 3733 views
    This topic created in 4849 days ago, the information mentioned may be changed or developed.
    re.search(r"(?:var).*",'var wumiiTitle ="some"').group())

    显示整个字符串 var wumiiTitle ="some"
    如果只要后面的,怎么写
    4 replies  •  1970-01-01 08:00:00 +08:00
    qdcanyun
    qdcanyun
    Aug 10, 2013
    1
    re.search(r"^var\s(.*)",'var wumiiTitle ="some"').group(1)
    yemoluo
    yemoluo
    Aug 11, 2013
    2
    re.search(r'var.*?=\s*\"(.*?)\"',s).group(1)
    yakczh
    yakczh
    OP
    Aug 12, 2013
    3
    group() 和group(0) 是不是一样?
    timonwong
    timonwong
    Aug 12, 2013
    4
    @yakczh
    是的,除此之外还能接收多个group参数,请参阅python re模块的文档。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2765 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 04:25 · PVG 12:25 · LAX 20:25 · JFK 23:25
    ♥ Do have faith in what you're doing.