Files
2024-03-21 20:32:50 +08:00

9 lines
202 B
Python

import re
str = "这是一段测试字符串,@机器人,请回答。"
pattern = r"@机器人"
matches = re.findall(pattern, str)
print(len(matches))
result = re.sub(pattern, "", str)
print(result)