正则表达式 python 查找数量和单词,以防数量位于段落末尾
regex python find amount and words in case that amount places at the end of paragraph
我需要在每个案例中罚款美元金额和金额后的单词并且没有可用的单词,那么我应该只有美元金额。美元金额放在段落末尾就是这种情况。
这是示例段落。
The cumulative effect resulted in a charge to incomeof ,001.9 million
(after reduction for income taxes of .4 million) in fiscal2001. Assuming
the accounting change had been applied retroactively by theCompany to prior
periods, pro forma net loss for fiscal 2000 and pro forma netincome for 1999
would have been (.3) million and .6 million, respectively.Net loss per
common share would have been ([=11=].57) in 2000, and net income perdiluted share
would have been [=11=].42 in 1999. Fiscal 2001 would have been 5.5 million and
net loss percommon share would have been ([=11=].02).
我要找
[,001.9 million, .4 million), (.3) million, .6 million, ([=12=].57) in,
[=12=].42 in, 5.5 million, ([=12=].02).]
无需正则表达式即可轻松完成此操作。
['$' + ' '.join(line.split(" ")[:2]) for line in text.split("$")[1:]]
我需要在每个案例中罚款美元金额和金额后的单词并且没有可用的单词,那么我应该只有美元金额。美元金额放在段落末尾就是这种情况。 这是示例段落。
The cumulative effect resulted in a charge to incomeof ,001.9 million
(after reduction for income taxes of .4 million) in fiscal2001. Assuming
the accounting change had been applied retroactively by theCompany to prior
periods, pro forma net loss for fiscal 2000 and pro forma netincome for 1999
would have been (.3) million and .6 million, respectively.Net loss per
common share would have been ([=11=].57) in 2000, and net income perdiluted share
would have been [=11=].42 in 1999. Fiscal 2001 would have been 5.5 million and
net loss percommon share would have been ([=11=].02).
我要找
[,001.9 million, .4 million), (.3) million, .6 million, ([=12=].57) in,
[=12=].42 in, 5.5 million, ([=12=].02).]
无需正则表达式即可轻松完成此操作。
['$' + ' '.join(line.split(" ")[:2]) for line in text.split("$")[1:]]