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
qanniu
V2EX  ›  Python

请教各位 正则表达式 别名 子串 匹配的问题?

  •  
  •   qanniu · 2015-11-07 00:55:24 +08:00 · 2467 次点击
    这是一个创建于 3095 天前的主题,其中的信息可能已经有所发展或是发生改变。
    想用别名来匹配这样的字符串里面的
    sum=4.375000
    发现不加别名可以,加了别名就无法匹配了?
    用如下表达式无效?? 为什么呢?
    sum=(?P<sum>(\d+(\.\d+)?))

    用如下表达式(移除别名)可以
    sum=(\d+(\.\d+)?)

    sum=((\d+(\.\d+)?))


    ========================

    sum=(?P<sum>\d+) 能匹配到
    sum=4
    3 条回复    2015-11-08 16:22:02 +08:00
    purensong
        1
    purensong  
       2015-11-07 07:25:56 +08:00
    没用过 python ,不过看懂了题主的意思,帮顶
    qanniu
        3
    qanniu  
    OP
       2015-11-08 16:22:02 +08:00 via iPhone
    感谢,是我用的编辑器问题,感谢回复,找到这个好用的在线监测工具
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3658 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 10:35 · PVG 18:35 · LAX 03:35 · JFK 06:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.