This is a routine task best done with two regexp's when using perl.
my $string = ' Mary had a little lamb. '; $string =~ s/^\s+//; #remove leading spaces $string =~ s/\s+$//; #remove trailing spaces print $string;
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.