I have to match text with this scheme:
Example:
my input text is: l''''text'''
the right output is: l'text
I've tried with:
re.sub(r"(\5)(?=((([\w\-\/](?<!'))+)('+)))", r"\2", text)
You could match the previously matched quotes after the string:
('+)([\w/-]+)\1
The \1 matches the exact same text group 1 matched.
Online demo at https://regex101.com/r/zQ0hM2/2.
Python session demo:
>>> import re
>>> text = "l''''text'''"
>>> re.sub(r'''('+)([\w/-]+)\1''', r'\2', text)
"l'text"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With