Please help on the below to get mentioned output using "re.sub"
import re year = '2025' source = '<publicationyear first=""/>' source = re.sub(r"(<publicationyear first=\")(\"/>)", fr"\1{year}\2", source) print(source)
Needed output: <publicationyear first="2025"/>
Tried in many sites but didn't get solutions with the combination of backreference and variable replacement.