--0015174fef2458a63f04a1c2c253 Content-Type: text/plain; charset=ISO-8859-1 Good Morning Michelle, On Mon, Apr 25, 2011 at 11:44 AM, Michelle Pace <michelle / michellepace.com>wrote: > Hello, I need to make the first string below into the second string. > That is, only single white spaces are permitted. > > "1/4 WELDING LEVER FRONT DRW 14844-C MAT WMA1CM-WLFRONT" > into > "1/4 WELDING LEVER FRONT DRW 14844-C MAT WMA1CM-WLFRONT" > > > > I want to use the sub! method. Why does the below code not work? Is my > pattern incorrect? > > descrip 1/4 WELDING LEVER FRONT DRW 14844-C MAT WMA1CM-WLFRONT" > descrip.sub!(/\s+/,' ') > puts descrip > Sub only replaces the first instance of the pattern. You require gsub! to accomplish your task. You noticed no difference with your sub! call because the first instance of your pattern is the single space between 1/4 and WELDING so in essence sub! did nothing to your string because it replaced a single space with a single space. John --0015174fef2458a63f04a1c2c253--