Skip to content

Instantly share code, notes, and snippets.

@digitalronin
Created May 15, 2023 06:24
Show Gist options
  • Save digitalronin/8d04752cfd1629827209f7150c93dfff to your computer and use it in GitHub Desktop.
Save digitalronin/8d04752cfd1629827209f7150c93dfff to your computer and use it in GitHub Desktop.
import re
def location(string):
match = re.match(r'^([A-Za-z,\s]+),\s*(?:\w+\s+)*\d{1,2},\s*\d{4}', string)
if match:
place = match.group(1)
return place.strip()
else:
return None
assert location("Houston, Texas, May 09, 2023 (GLOBE NEWSWIRE) -- via IBN -- BlockQuarry Corp. (OTC: BLQC) announces its sponsorship of a custom community tournament for the popular NFT-based horse racing game, Zed...") == "Houston, Texas"
assert location("LAS VEGAS, April 27, 2023 (GLOBE NEWSWIRE) -- CleanSpark, Inc. (Nasdaq: CLSK), America's Bitcoin Miner™, will discuss fiscal second quarter 2023 financial results via a live webcast beginning 4:30...") == "LAS VEGAS"
assert location("SINGAPORE, May 02, 2023 (GLOBE NEWSWIRE) -- As a cryptocurrency exchange favored by individual investors and experiencing rapid growth, BYDFi has always been committed to providing users with...") == "SINGAPORE"
assert location("NEW YORK, NY, May 02, 2023 (GLOBE NEWSWIRE) -- International Endeavors Corp. (“IEC”) (OTC PINK: IDVV), a technology holdings company with a growing portfolio of assets in the artificial intelligence...") == "NEW YORK, NY"
assert location("MIAMI, April 27, 2023 (GLOBE NEWSWIRE) -- via Web3MediaWire -- Mona Shaikh is a veteran comedian, featured on CNN, Forbes, MSNBC and producer of ""Mona& Frens: Web3 Is A Joke."" In collaboration...") == "MIAMI"
assert location("LAS VEGAS, April 27, 2023 (GLOBE NEWSWIRE) -- CleanSpark, Inc. (Nasdaq: CLSK), America's Bitcoin Miner™, will discuss fiscal second quarter 2023 financial results via a live webcast beginning 4:30...") == "LAS VEGAS"
assert location("STOCKHOLM , May 08, 2023 (GLOBE NEWSWIRE) -- A Philanthropic Cryptocurrency Bringing the Spirit of Giving to the BlockchainThe innovative memecoin project shares ambitious plans for integrating...") == "STOCKHOLM"
assert location("TORONTO, May 05, 2023 (GLOBE NEWSWIRE) -- Virgo Global Holdings Inc., the holding company of VirgoCX Inc. and other companies (“Virgo Group”), is pleased to announce the acquisition of Toronto-based...") == "TORONTO"
assert location("Markham, May 04, 2023 (GLOBE NEWSWIRE) -- Cryptocurrency investment firm CFund Capital Canada Inc. (hereinafter referred to as ""CFund"") will participate in the North American Blockchain Technology...") == "Markham"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment