简体   繁体   中英

How to extract text at newline using regex pattern with python?

My text is as follow:

"""
2.Consignee

VU TRINI GIA BAO SERVICE AND TRADING JOINY STOCK COMPANY
44/26 VO VAN DONG, STREET, O CHU DUA WARD



"""

What is the suitable regular expression pattern for me to extract out the value aft the title consignee?

Desired output:

VU TRINI GIA BAO SERVICE AND TRADING JOINY STOCK COMPANY
44/26 VO VAN DONG, STREET, O CHU DUA WARD

This might not be that generic, but I guess this gives what you expect:

print(re.sub("(?i)[. \n 0-9]*Consignee", "", re.sub("\n\n", "", text)))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM