A Formula for the Geometric Jacquet Functor and its Character Sheaf Analogue