Yeah I do that in java actually, just here since a replace method was already available I used that. 

Problem was e.g. for {connections}/resources it would replace {connections} with the blank string if it wasn't in the map. Could add a flag to the replace method to say it should replace with the contents of {} when the flag is present though.