繁体   English   中英

字符串:仅删除引号后的数字

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM