正则表达式 匹配标点符号
import re text = "Hello, world! This is a \"small\" example. Can you handle it?" pattern = r'[,.!"\']' result = re.sub(pattern, ' ', text) print(result)
import re text = "Hello, world! This is a \"small\" example. Can you handle it?" pattern = r'[,.!"\']' result = re.sub(pattern, ' ', text) print(result)
