You can delete white spaces at the start and at the end of a string like
this:
string=" a long string "
string1=string.sub(/^ +/,‘’)
string2=string.sub(/ +$/,‘’)
The ^ stands for eliminating things at the start, the + stands for
eliminating
1 or more occurrences of a whitespace, and the $ stands for looking to
the
end of a string.
I can’t comment on whether it’s the best way to learn about Regexp, but
http://www.regular-expressions.info
(http://www.regular-expressions.info)
has a special Ruby section.
If you want to know it all, there is a book Mastering Regular
Expressions
by Jeffrey Friedl, published with O’Reilly … but maybe that’s too
much
for a start.
Best regards,
Axel