You can delete white spaces at the start and at the end of a string like
string=" a long string "
The ^ stands for eliminating things at the start, the + stands for
1 or more occurrences of a whitespace, and the $ stands for looking to
end of a string.
If you want to know it all, there is a book Mastering Regular
by Jeffrey Friedl, published with O’Reilly … but maybe that’s too
for a start.