Fix remove_notifications() for strings with multiple occurrences.
parent
f5c7ac30f7
commit
71b3ab2bf6
9
utils.py
9
utils.py
|
@ -44,10 +44,13 @@ def remove_notifications(text):
|
|||
"soren",
|
||||
]
|
||||
|
||||
def replace(match):
|
||||
# Insert <i></i> after the first character of the matched string.
|
||||
user = match.group()
|
||||
return f"{user[:1]}<i></i>{user[1:]}"
|
||||
|
||||
for user in notified_users:
|
||||
match = re.search(user, text, re.IGNORECASE)
|
||||
if match:
|
||||
text = f"{text[:match.start() + 1]}<i></i>{text[match.start() + 1:]}"
|
||||
text = re.sub(user, replace, text, flags=re.IGNORECASE)
|
||||
|
||||
return text
|
||||
|
||||
|
|
Loading…
Reference in New Issue