How do I use the replace function to replace all instances with the exception of one.
mystr = "he said: 'hi my name's Jim'."
mystr.replace("'", '"')
print(mystr)
The output I would want is:
he said: "hi my name's Jim".
How do I exclude 's from the replace? ie exclude all ' followed by an s and where the ' is preceded by digit/letter.
if mystr2 = "'s: hi'" then I wouldn't want to replace the first ' only replace the second '.
UPDATE Removing single quotes if they aren't in the middle of a word This shows how to remove the required quotes, but not how to replace it.