正则表达式 匹配标点符号

import re

text = "Hello, world! This is a \"small\" example. Can you handle it?"
pattern = r'[,.!"\']'
result = re.sub(pattern, ' ', text)
print(result)

 

posted @ 2023-12-28 14:18  myrj  阅读(25)  评论(0编辑  收藏  举报