import re
note = "I am presently having coffee with @example. #coffee #lunch #breakfast" #* 10000
person_tags_reference = {
"example": ("Example Person", "example.com/bio"),
}
tags = ["coffee", "lunch", "breakfast"]
tags = {tag: tag for tag in tags}
note_tags = re.findall(r"#(\w+)", note)
person_tags = re.findall(r"@(\w+)", note)
all_tags = list(set(note_tags))
for tag in all_tags:
if tags.get(tag):
note = note.replace(
"#" + tag, f"#{tag}"
)
for tag in list(set(person_tags)):
if person_tags_reference.get(tag):
note = note.replace(
"@" + tag,
f"@{person_tags_reference[tag][0]}",
)
print(note)
Tagged in code snippets, python.