I have a string similar to the "cow"1 jumped "over"2 the moon and the "spoon"3... this happened 123 times
I want to remove only the numbers following a quotation mark: the "cow" jumped "over" the moon and the "spoon"... this happened 123 times
Try this:
See the regex pattern here .
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.