python-3.x - 如何使用正则表达式从带有条件的字符串中提取特定值
问题描述
我的输入字符串
This is Bruno. He is a service shark. Only gets out of the 12.5/11 water to assist you. 13.5/10 terrifyingly good boy
在上面的字符串中,我想提取13.5
而不是12.5
所以我这样做了:这是代码
a = re.search(r"\d*\.\d+|\d+\/\'10'", text)
print(a.group())
# 12.5
我该怎么做?
解决方案
推荐阅读
- mysql - 如何在每行上乘以 2 列并使用 Sequelize 对所有结果求和?
- python-3.x - 用熊猫从同一列的另一行中减去一行
- javascript - 正则表达式匹配时后跟空格或没有空格
- c++ - 如何成功重新编程 MAXREFDES100#?
- python - INFO:tensorflow:Error 报告给 Coordinator:
, - java - 无法从发布 apk 登录使用 Firebase 身份验证(无 Google Play)
- apache-spark - 从模式字符串 Java-Spark 创建 JSON 模式
- r - 阿拉伯语 WordCloud R Studio
- sql - 插入语句中同一列的两个 case 语句
- c# - ConcurrentDictionary Remove() 不可访问