Regex locate number followed by space followed by character [duplicate]

  python, python-3.x, regex

I tried to locate only characters followed by space and a character after it.

Exemple : text = "3 R"

and want it to be like this :

Exemple : text = "3. R"

i’ve tried this code :

text= re.sub(r'([0-9])(?!.*d)', r'. ', text)

Am getting closer but don’t know what should i add to it.

PS: the code turns 9h to 9. h which i don’t want .

Source: Python Questions

LEAVE A COMMENT