From: Josh Cheek Date: 2010-08-30T10:24:49+09:00 Subject: Re: gsub blank --0016364d299383752a048f00546d Content-Type: text/plain; charset=ISO-8859-1 On Sun, Aug 29, 2010 at 8:11 PM, Pen Ttt wrote: > irb(main):011:0> " gk".gsub("\s","h") > => "hhhhhgk" > irb(main):012:0> " gk".gsub("\s+","h") > => " gk" > how can i make " gk" into "hgk"? > -- > Posted via http://www.ruby-forum.com/. > > Your second example is almost there, except that it is a String, not a Regexp. Regexp are enclosed with slashes rather than quotes (Regexp has it's own literal, as opposed to languages like Java, where it needs to be defined within a String) " gk".gsub( /\s+/ , "h") # => "hhghkh" --0016364d299383752a048f00546d--