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

python 正则表达式的问题

  •  
  •   Alpha ·
    PRO
    ·
    alphachoi · Apr 30, 2011 · 5539 views
    This topic created in 5631 days ago, the information mentioned may be changed or developed.
    str = 'var html = new Array("a","b","c"); var text = "(new python book)";'
    如何将字符串 ("a","b","c")匹配出来?

    我的思路是想这样,但语法肯定不对,这其中的小括号怎么转义或匹配?
    p = re.compile(r"(?+)?")

    print p.match(str).group()
    1 replies  •  1970-01-01 08:00:00 +08:00
    aligo
        1
    aligo  
       Apr 30, 2011
    re.findall("(\(.+?\))", str)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4194 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:02 · PVG 18:02 · LAX 03:02 · JFK 06:02
    ♥ Do have faith in what you're doing.