I am trying to change all strings of the type a.b to a. b. It should also work if any of the characters are capital case. Note that a. should not be changed to a.\(space).
I have tried using regex to do this like so:
a = "a.b"
a = re.sub(r'[a-b]\.[a-b]', ' .', a)
The output should be a. b, but it is ., because it replaces all the characters as well, instead of keeping the characters and just putting a space after the dot.
Does anyone know how to do this in Python?
Edit: I am trying to add a space when there is a period in between two sentences. However, I can't use str.replace, since it would add a space in this case also, like 1.5 becoming 1. 5, which is not what I want. I tried to do regex, but wasn't able to get it to work.
Also, this has to work in all possible sentences, not just a.b