regex remove whitespace python first and last character code example Example: python trim whitespace from end of string >>> " xyz ".rstrip() ' xyz'