 <p>Building on @barak manos' idea, i would just go and look for all my dictionary keys in every line and replace them on site like so:</p> <pre><code>dict = { '¼': '.25', '½': '.50', } def convert(line, dict): for x in dict: line = line.replace(x, dict[x]) line = line.replace(' ' + dict[x], ' 0' + dict[x]) return line a = '1¼ ½ 564as 25½' print(convert(a,dict)) # returns: '1.25 0.50 564as 25.50' </code></pre> <p>The position of the characters you are looking for in the sentence and/or the presence of integers around them or not is irrelevant.</p>