Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #3521
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!talisker.lacave.net!lacave.net!not-for-mail |
|---|---|
| From | Joel VanderWerf <joelvanderwerf@gmail.com> |
| Newsgroups | comp.lang.ruby |
| Subject | Re: Replace any multiple whitespaces with single white space |
| Date | Tue, 26 Apr 2011 11:31:32 -0500 |
| Organization | Service de news de lacave.net |
| Lines | 27 |
| Message-ID | <4DB6F34F.9060509@gmail.com> (permalink) |
| References | <c7e16b34811c4729c009d79c4c2eef4d@ruby-forum.com> <4DB5C2CA.3070705@gmail.com> <a880d1c094116d3d1f420a8a19b64e88@ruby-forum.com> |
| NNTP-Posting-Host | bristol.highgroove.com |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| X-Trace | talisker.lacave.net 1303835511 32708 65.111.164.187 (26 Apr 2011 16:31:51 GMT) |
| X-Complaints-To | abuse@lacave.net |
| NNTP-Posting-Date | Tue, 26 Apr 2011 16:31:51 +0000 (UTC) |
| In-Reply-To | <a880d1c094116d3d1f420a8a19b64e88@ruby-forum.com> |
| X-Received-From | This message has been automatically forwarded from the ruby-talk mailing list by a gateway at comp.lang.ruby. If it is SPAM, it did not originate at comp.lang.ruby. Please report the original sender, and not us. Thanks! For more details about this gateway, please visit: http://blog.grayproductions.net/categories/the_gateway |
| X-Mail-Count | 382208 |
| X-Ml-Name | ruby-talk |
| X-Rubymirror | Yes |
| X-Ruby-Talk | <4DB6F34F.9060509@gmail.com> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.ruby:3521 |
Show key headers only | View raw
On 04/26/2011 05:03 AM, Brian Candler wrote: > Joel VanderWerf wrote in post #994935: >> On 04/25/2011 11:44 AM, Michelle Pace wrote: >>> pattern incorrect? >>> >>> descrip = "1/4 WELDING LEVER FRONT DRW 14844-C MAT WMA1CM-WLFRONT" >>> descrip.sub!(/\s+/,' ') >>> puts descrip >> >> sub! only affects the *first* match. You can substitute globally with >> gsub. Also you might as well only match 2 or more spaces: >> >> descrip.gsub!(/\s\s+/,' ') > > Those are not equivalent, because \s matches more than just ASCII 0x20. > > d1 = "foo\tbar\tbaz" > d1.gsub(/\s+/,' ') # "foo bar baz" > d1.gsub(/\s\s+/,' ') # "foo\tbar\tbaz" You're right. What I said in another post about preserving tabs isn't what the original sub! call was doing anyway. (sorry for the empty reply previously)
Back to comp.lang.ruby | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Replace any multiple whitespaces with single white space Michelle Pace <michelle@michellepace.com> - 2011-04-25 13:44 -0500
Re: Replace any multiple whitespaces with single white space Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-04-25 13:51 -0500
Re: Replace any multiple whitespaces with single white space Josh Cheek <josh.cheek@gmail.com> - 2011-04-25 14:02 -0500
Re: Replace any multiple whitespaces with single white space Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-04-25 14:14 -0500
Re: Replace any multiple whitespaces with single white space Gunther Diemant <g.diemant@gmx.net> - 2011-04-25 15:43 -0500
Re: Replace any multiple whitespaces with single white space Brian Candler <b.candler@pobox.com> - 2011-04-26 07:03 -0500
Re: Replace any multiple whitespaces with single white space Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-04-26 11:27 -0500
Re: Replace any multiple whitespaces with single white space Joel VanderWerf <joelvanderwerf@gmail.com> - 2011-04-26 11:31 -0500
Re: Replace any multiple whitespaces with single white space John W Higgins <wishdev@gmail.com> - 2011-04-25 13:56 -0500
Re: Replace any multiple whitespaces with single white space Alexander McMillan <alexandermcmillan@hotmail.com> - 2011-04-26 05:18 -0500
csiph-web