我需要删除所有出现的单个分号,但保留两个出现的分号。你知道吗
输入:
poop,hello\/# what;up,\wor;;ld; yolo| s|ag"j"d\nhdhf,\;;
预期产量:
poop hello what up wor;;ld yolo| s|ag"j"d hdhf ;;
所以,除了出现一个分号外,我可以删除所有内容。你知道吗
a=re.sub(r'[^\w|\d|(;;)|\|"]'," ",a)
其中a
是显示在顶部的字符串。你知道吗
但它给了我:
poop hello what;up wor;;ld; yolo| s|ag"j"d hdhf ;;
这里怎么了?你知道吗
尝试:
将
;;
替换为$
,而将;
替换为空格,而不是替换回;;
。你知道吗您可以使用负向前看和负向后看:
相关问题 更多 >
编程相关推荐