不是基于正则表达式的解决方案。但是,把戏。
a='''SLINC SHORT LEGAL TITLE NUMBER0037 471 661 1720278;16;21172 211 342LEGAL DEscriptIonPLAN 1720278 BLOCK 16 LOT 21 EXCEPTING THEREOUT ALL MINES AND MINERALSESTATE: FEE SIMPLE ATS REFERENCE: 4;24;54;2;SWMUNICIPALITY: CITY OF EDMonTONREFERENCE NUMBER: 172 023 641 +71---------------------------------------------------------------------------- ---- REGISTERED OWNER(S)REGISTRATION DATE(DMY) document TYPE VALUECONSIDERATION--------------------------------------------------------------------------- -- ---172 211 342 15/08/2017 AFFIDAVIT OF CASH & MTGE'''doc = (a.split('15/08/2017', 1)[1]).strip() # used split with two white spaces instead of one to get the desired resultprint(doc.split(" ")[0].strip()) # outputs AFFIDAVIT OFprint(doc.split(" ")[-1].strip()) # outputs CASH & MTGE
希望能帮助到你。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)