Ruby / Rails: Remove Extra Space
…or anything else you want from a string.
" myemail @ address. co m ".gsub(/\s/, '')
gsub() substitutes all instances found (g = global), if you just want to substitute the first instance use sub()
Or, if you want to trim the whitespace from each end:
result = " myemail@address.com ".strip
To just trim the whitespace on the left or the right, use these (respectively):
lstrip()
rstrip()