Hello, 2 hours later and Good Monday is loosing it's "good'ness"!! :) I need to make the first string below into the second string, that is only single white spaces are permitted so multiple white spaces (shown as "____" in the text below) must be replaced.

"1/4 WELDING______LEVER____FRONT DRW_____14844-C__MAT____WMA1CM-WLFRONT"
into: "1/4 WELDING LEVER FRONT DRW 14844-C MAT WMA1CM-WLFRONT"

Is there something wrong with my pattern below, for the life of me I can not figure it out?

descrip = "1/4 WELDING    LEVER FRONT DRW 14844-C  MAT  WMA1CM-WLFRONT"
descrip.sub!(/\s+/,' ')
puts descrip  # this just gives me back exactly the string I set descrip to above

A biiiiiiig thank-you in advance,
Michelle

Recommended Answers

All 2 Replies

Use gsub()

descrip.gsub!(/\s+/,' ')

:) thank-you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.