XXXXX bushels/contracts/barrels ..... at $XXX,XXX.00 .....
第二个词可以是:
[bushels, contracts, barrels]
$
符号是可选的
....
节可以是任何东西。
我很难弄清楚价格
以下是一些例句:
58,664 barrels at $102,020.00 - 2011-01-20 03:28:37
58,664 contracts at 102,020.00 USD - 2011-01-20 03:28:37
58,664.20 bushels at 102,020.0 - 2011-01-20 03:28:37
amount, *_ = re.match(r'([0-9,\.]+)', str).groups()
我陷入困境的是价格。出于某种原因,
re.match
None
以下是我尝试的查询:
price, *_ = re.match(r"(?<=at )[\$\.\,0-9]*", amount).groups()
price, *_ = re.match(r"at (?:\$)?([0-9,\.]+)", amount).groups()
None.groups()
NoneType
错误。
我不知道为什么不匹配。我疯了吗?我有什么明显的遗漏吗?