import re PRONOUN_REPLACE_REGEX = re.compile(r"\[\S*\]") class PronounUpdate: pronouns: str def __init__(self, pronouns: str): self.pronouns = pronouns def replace_pronouns_in_bio(self, bio: str) -> str: return PRONOUN_REPLACE_REGEX.sub(f"[{self.pronouns}]", bio)