Replace use of regular expressions by string formatting