How do I remove trailing whitespace using a regular expression? January 27, 2023 by Tarik Try just removing trailing spaces and tabs: [ \t]+$