With that terse description and the subject line I would interpret the OP like so: >>> print re.sub(".*\.",".","0.666") .666 >>> print re.sub(".*\.",".","123.666") .666