Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with gsub

Status
Not open for further replies.

janolan

Programmer
Joined
May 31, 2005
Messages
4
Location
US
I have a string that I need to fill up the white space with a plus "+" sign. When I use gsub, it also puts the + sign at the beginning of the string. How can I get the + sign just in the white space of the string but not at the beginning?

Instruction: gsub(/ /, "+", $3);

Input line:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)

Current output:
+Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1)
 
quick and dirty:
gsub(/ /, "+", $3); $3=substr($3,2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thank you! Works perfectly!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top