9 lines
202 B
Python
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) |