[英]How to remove specific character in string if it is in quotation mark Python
[英]String: Only Remove Numbers Following a Quotation Mark
我有一个类似于the "cow"1 jumped "over"2 the moon and the "spoon"3... this happened 123 times
我只想删除引号后面的数字: the "cow" jumped "over" the moon and the "spoon"... this happened 123 times
尝试这个:
请参阅此处的正则表达式模式。
import re
string = 'the "cow"1 jumped "over"2 the moon and the "spoon"3... this happened 123 times'
pat = r"(?<=\")(\d+)"
out = re.sub(pat, "", string)
print(out)
the "cow" jumped "over" the moon and the "spoon"... this happened 123 times
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.