Trim string for correct keys