使用python正则表达式在多行字符串之后提取字符串

时间:2018-12-31 04:09:17

标签: python regex python-3.x

我有一个字符串

a='''S
LINC             SHORT LEGAL                                   TITLE NUMBER
0038 073 623     1522744;27                                    182 246 612 
+5

LEGAL DESCRIPTION
CONDOMINIUM PLAN 1522744  
UNIT 27  
AND 237 UNDIVIDED ONE TEN THOUSANDTH SHARES IN THE COMMON PROPERTY  
EXCEPTING THEREOUT ALL MINES AND MINERALS  

ESTATE: FEE SIMPLE  
ATS REFERENCE: 4;25;52;8;NW

MUNICIPALITY: CITY OF EDMONTON

REFERENCE NUMBER: 172 303 453 +7

---------------------------------------------------------------------------- 
----
         REGISTERED OWNER(S)
REGISTRATION    DATE(DMY)  DOCUMENT TYPE      VALUE           CONSIDERATION
---------------------------------------------------------------------------- 
----

182 246 612    01/10/2018  PHASED OF                           CASH & MTGE
                           CONDOMINIUM PLAN                    '''

我需要在单词“ PHASED OF CONDOMINIUM PLAN”之后获取字符串,该字符串应返回“ CASH&MTGE” 我尝试使用下面的表达式

date_value = (re.search(r'(\d+/\d+/\d+)', a)).group(1) //returns '01/10/2018'
doc_type = "".join(list(re.search(r"(?<={})\s*((?:\S+\s)+).*\s*((?:\S+\s)+)".format(date_value),a).group(1, 2))).strip() //returns 'PHASED OF CONDOMINIUM PLAN' 
consideration = ((re.search(r"(?<={}).*".format(doc_type),a)).group()).strip()

我找不到任何匹配项

0 个答案:

没有答案