Wednesday, March 26, 2008

Remove leading and trailing whitespace

To remove leading and trailing whitespace(or any trailing char):

  • Regular Expression :
    • s/^\s+//;
    • s/\s+$//;
  • Perl :
    • Chomp();
  • Python:
    • strip();

No comments: