omg, you people need to validate that it is base58 also (why so low quality answers are upvoted, what's wrong with you people???)
code in python
def extract_solana_addresses(text) -> set:""" Extracts potential Solana addresses from text and validates them as base58. Parameters: text (str): The input text to search for Solana addresses. Returns: set: A set of unique, validated Solana addresses.""" # Regular expression for base58-compatible strings (32 to 44 characters) pattern = r"\b[1-9A-HJ-NP-Za-km-z]{32,44}\b" # Find all potential matches candidates = re.findall(pattern, text) # Filter only valid base58-encoded strings valid_addresses = set() for candidate in candidates: try: # Decode using base58 to ensure it's valid decoded = base58.b58decode(candidate) # Optional: Validate length (32 bytes is standard for Solana) if len(decoded) == 32: valid_addresses.add(candidate) except Exception: # Ignore invalid base58 strings continue return valid_addresses