import re def clean_tags(tags): # Make tags more human readable tags = tags.replace(' ', ', ').replace('_', ' ') # Remove "!", "?", ".", "(", ")" from the tags tags = re.sub(r"[!.?()]", "", tags) # Replace " , " with an empty space tags = re.sub(r" , ", " ", tags) # Remove any trailing commas tags = re.sub(r"^,|,$", "", tags) # Strip spaces tags = tags.strip() # Remove any usernames words = tags.split(", ") result = [] for word in words: word = word.strip() if word == 'v': result.append(word) continue if len(word) < 2: continue if any(char.isdigit() for char in word) and word not in ["1girl", "1boy", "1koma", "1other"]: continue result.append(word) return ", ".join(result)