【发布时间】:2015-10-05 22:57:57
【问题描述】:
我已经阅读了很多页面,试图解释如何将regex 用于 Python,但我仍然完全不明白。甚至regex wiki 和re documentation 也帮不了我。我仍然有点困惑:P
我有以下字符串:
string = "|C195|1|Base de Cálculo ST: 2.608,24 - Valor da ST: 163,66|"
我正在尝试仅提取 2.608,24 和 163,66 使用:
st_values = re.findall("\d+[,.]\d+", string)
但是,我的print st_values 的输出是:
['2.608','163,66']
相反,我希望它是
['2.608,24','163,66']
我不想
['195', '1', '2.608,24','163,66']
那么,我该如何使用正则表达式参数的字母汤来提取它们呢?
【问题讨论】:
标签: python regex string python-2.7 extract