I use a much shorter regex. I don't have my code in front of me, but if I can remember correctly it is:
$string =~ s/^\s+//; # Trim leading white-space $string =~ s/\s+$//; # Trim trailing white-space Hope this helps...just another way of doing it. - Chris