trim strings when substituting tokens