【发布时间】:2016-11-21 14:08:19
【问题描述】:
我尝试通过这种模式使用正则表达式解析字符串
text1 (text2 500g OR kg text3) text4
示例
1.tomato (more 500g)
2.potatoes (1 kg)
3.potatoes (10 kg) onion
我如何使用重新提取 text1+text4
1. tomato 2. potatoes 3. potatoes onion
【问题讨论】:
-
您的示例似乎与您的要求不一致 - 您已经注意到您需要 text1 和 text2,但您的示例 #3 显示 text1 和 text4。考虑让这个问题更清楚。
标签: regex python-3.x expression