2017-07-28 70 views
-2

末尾的金额的地方我需要罚金美元金额和话后,在每个案件的金额和单词不可用,那么我应该只有美元金额。段落末尾的美元金额就是这种情况。 这是示例段落。正则表达式蟒蛇找到金额和字的情况下,在第

The cumulative effect resulted in a charge to incomeof $1,001.9 million 
(after reduction for income taxes of $6.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 ($17.3) million and $12.6 million, respectively.Net loss per 
common share would have been ($0.57) in 2000, and net income perdiluted share 
would have been $0.42 in 1999. Fiscal 2001 would have been $255.5 million and 
net loss percommon share would have been ($0.02). 

我想找到

[$1,001.9 million, $6.4 million), ($17.3) million, $12.6 million, ($0.57) in, 
$0.42 in, $255.5 million, ($0.02).] 
+1

你到目前为止尝试了什么? – nutmeg64

+0

你在这里做了很多事情,在千位以及标点符号上变得复杂。我认为这个正则表达式是不可靠的,因为你从语言中挑选它。 – sln

+0

@ nutmeg64我试着用[\ $] {1} [\ d,] + \。?\ d {0,2}(\ w +) – MMM

回答

1

您可以轻松地做到这一点没有正则表达式。

['$' + ' '.join(line.split(" ")[:2]) for line in text.split("$")[1:]]