How to create a RE in Python to add whitespace in front of these special characters ,?!
if these special characters stick to a word?
Here is the input string:
myString= 'I like him, but is he good? Maybe he is good , smart, and strong.'
Desired output (if the special character doesn't stick to a word, it is not modified):
modifiedString= 'I like him , but is he good ? Maybe he is good , smart , and strong.'
I have tried this re:
modifiedString= re.sub('\w,' , ' ,' ,myString)
But it gives the wrong result. It removes the last character before coma, here's the result example:
modifiedString = 'I like hi , but is he good? Maybe he is goo , smar , and strong.'
Any suggestion to solve this problem?