genshin-wiki/utils/funcs.py

15 lines
332 B
Python
Raw Permalink Normal View History

2023-05-02 14:21:08 +00:00
try:
import regex as re
except ImportError:
import re
__all__ = ("remove_rich_tag",)
reich_pattern = r"(<(?P<tag_name>[a-z]+?)=(?P<value>.+?)>.+?</(?P=tag_name)>)"
2023-05-02 14:21:08 +00:00
def remove_rich_tag(string: str | None) -> str:
"""去除富文本标签"""
if string is not None:
return re.sub(reich_pattern, "", string)