Python文本处理和文本解析损益表

Python文本处理和文本解析损益表,python,parsing,text-processing,Python,Parsing,Text Processing,我想咨询一下如何处理损益表中的文本。我一直在尝试使用这些表,但发现它们的结构太多样化,无法可靠地解析。我想改为使用文本处理,因为这些报告使用以下措辞: Consolidated third quarter net earnings were $72 million, or $0.93 per share Net loss attributable to common shareholders for the first quarter of 2015 totaled $4.9 million,

我想咨询一下如何处理损益表中的文本。我一直在尝试使用这些表,但发现它们的结构太多样化,无法可靠地解析。我想改为使用文本处理,因为这些报告使用以下措辞:

Consolidated third quarter net earnings were $72 million, or $0.93 per share
Net loss attributable to common shareholders for the first quarter of 2015 totaled $4.9 million, or $0.02 per basic and diluted share
Non-GAAP Diluted EPS from Continuing Operations of $1.48
Non-GAAP net income per diluted share of $0.44
这种模式非常明显,有很多净收益、每股收益和/或非公认会计原则,但我从未做过文本处理,我想知道是否有一个简单的框架可以让这种方法更简单


谢谢你的建议

我想你需要的是这个。如果你以前没有使用过正则表达式,那么期待一个学习曲线。我以前使用过re,但我当然不是一个超级粉丝。不过,我很可能会在那里结束。谢谢。看看这个网站。这是学习正则表达式时使用的一个好工具。美好的是的,我只是在另一个测试网站上。这一切进展顺利。谢谢您可以查看pyparsing模块来构建比使用re更可读、更简单的解析器