Replace brackets with escape characters.