5% assure discount from here only

Tuesday, January 25, 2011

(7) How do I strip blank space from the beginning/end of a string?

Solution :

A substitution can do this for you. For a single line, you want to
replace all the leading or trailing whitespace with nothing. You
can do that with a pair of substitutions:

(i) To remove leading space
s/^\s+//;

(ii) To remove Trailing space
s/\s+$//;

No comments:

Post a Comment