-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ZacharyHampton/all_3_sites
feat: run all 3 sites with one call
- Loading branch information
Showing
4 changed files
with
80 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
import re | ||
|
||
|
||
def parse_address_two(address_one: str): | ||
apt_match = re.search(r"(APT\s*.+|#[\s\S]+)$", address_one, re.I) | ||
return apt_match.group().strip() if apt_match else None | ||
def parse_address_two(street_address: str): | ||
if not street_address: | ||
return None | ||
apt_match = re.search( | ||
r"(APT\s*[\dA-Z]+|#[\dA-Z]+|UNIT\s*[\dA-Z]+|LOT\s*[\dA-Z]+)$", | ||
street_address, | ||
re.I, | ||
) | ||
|
||
if apt_match: | ||
apt_str = apt_match.group().strip() | ||
apt_str = re.sub(r"(APT\s*|UNIT\s*|LOT\s*)", "#", apt_str, flags=re.I) | ||
return apt_str | ||
else: | ||
return None | ||
|
||
|
||
if __name__ == "__main__": | ||
print(parse_address_two("810 E Colter St APT 32")) | ||
print(parse_address_two("1234 Elm Street apt 2B")) | ||
print(parse_address_two("1234 Elm Street UNIT 3A")) | ||
print(parse_address_two("1234 Elm Street unit 3A")) |