2024-05-15 05:50:57 发布
网友
我想从下面的字符串中一段(字符串)中解析出“$1000.00”:
“在等待了近三个月后丢失了一个书架($1000.00)。“
我的正则表达式应该如何设计关于芬德尔()功能?谢谢!在
我尝试的是re.findall(r"\d+[.,]?\d+", text),我只得到: ['1000','00']
re.findall(r"\d+[.,]?\d+", text)
但是,我希望我的输出是: ['$1000.00']
How to find Price Tag with Dollar Sign, thousand delimiter AND decimal point by Python Regex
money_parser egg正是您需要的:
安装:
pip install money_parser
用法:
您可以使用类似于:
x = "lost a bookcase ($1,000.00) after waiting for nearly three months." result = re.findall(r"\b\$?[\d,.]+\b", x)
['1,000.00']
Regex DemoPython Demo
正则表达式解释
注意事项:
\b\$?[\d,.]+\b
money_parser egg正是您需要的:
安装:
用法:
^{pr2}$旧答案
您可以使用类似于:
['1,000.00']
Regex Demo
Python Demo
正则表达式解释
注意事项:
\b\$?[\d,.]+\b
,但足以让您 起动。在^{4}$
相关问题 更多 >
编程相关推荐