我有不同格式的街道地址字符串。我试过这个老post,但没有多大帮助。我的字符串格式如下,
格式1:
string_1 = ', landlord and tenant entered into a an agreement with respect to approximately 5,569 square feet of space in the building known as "the company" located at 788 e.7th street, st. louis, missouri 55605 ( capitalized terms used herein and not otherwise defined herein shall have the respective meanings given to them in the agreement); whereas, the term of the agreement expires on may 30, 2015;'
期望的输出:
788 e.7th street, st. louis, missouri 55605
格式2:
string_2 = 'first floor 824 6th avenue, chicago, il where the office is located'
期望的输出:
824 6th avenue, chicago, il
格式3:
string_3 = 'whose address is 90 south seventh street, suite 5400, dubuque, iowa, 55402.'
期望的输出:
90 south seventh street, suite 5400, dubuque, iowa, 55402
到目前为止,我试过,这是为了string_1
,
address_match_1 = re.findall(r'((\d*)\s+(\d{1,2})(th|nd|rd).*\s([a-z]))', string_1)
我得到一个空列表。
对于第二个字符串,我尝试了同样的方法,得到如下的空列表,
address_match_2 = re.findall(r'((\d*)\s+(\d{1,2})(th|nd|rd).*\s([a-z]))', string_2)
我怎样才能尝试使用re
进行匹配?它们都有不同的格式,我怎样才能让套件参与string_3
?任何帮助,将不胜感激。