In Ruby, sometimes I need to remove the new line character at the beginning of a string. Currently what I did is like the following. I want to know the best way to do this. Than
strip will remove all trailing whitespace
strip
s = "\naaaa\nbbbb" s.strip!
Little hack to chomp leading whitespace:
str = "\nmy string" chomped_str = str.reverse.chomp.reverse