in reply to regexp problem

jeanluca,
Perhaps I am being dense but it sounds like what you want to do is remove leading and trailing whitespaces. This is a FAQ IIRC. In any case - the following should do the trick:
$str =~ s/^\s+|\s+$//g;

Cheers - L~R