Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.ruby > #7395
| X-Received | by 2002:a6b:1881:: with SMTP id 123-v6mr2865475ioy.8.1530807051676; Thu, 05 Jul 2018 09:10:51 -0700 (PDT) |
|---|---|
| X-Received | by 2002:aca:4787:: with SMTP id u129-v6mr1462246oia.4.1530807051536; Thu, 05 Jul 2018 09:10:51 -0700 (PDT) |
| Path | csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!d7-v6no2773506itj.0!news-out.google.com!l67-v6ni2805itl.0!nntp.google.com!u78-v6no2746129itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.ruby |
| Date | Thu, 5 Jul 2018 09:10:51 -0700 (PDT) |
| In-Reply-To | <442165f5-c8c9-4273-8762-65a86a23bc5c@googlegroups.com> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=161.69.135.20; posting-account=MGO7qgoAAABvyo26eHVDO00044spH-ws |
| NNTP-Posting-Host | 161.69.135.20 |
| References | <442165f5-c8c9-4273-8762-65a86a23bc5c@googlegroups.com> |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <7f511e6f-cadd-4048-b2b2-e153ca86eb64@googlegroups.com> (permalink) |
| Subject | Re: Ultimate Guide to Ruby Strings |
| From | Robert Klemme <shortcutter@googlemail.com> |
| Injection-Date | Thu, 05 Jul 2018 16:10:51 +0000 |
| Content-Type | text/plain; charset="UTF-8" |
| Lines | 41 |
| Xref | csiph.com comp.lang.ruby:7395 |
Show key headers only | View raw
On Sunday, February 4, 2018 at 7:00:17 PM UTC+1, Jesus Castello wrote: > Hello! > I wrote an article about ruby string methods on my blog rubyguides. > > You can read it here: > > http://www.rubyguides.com/2018/01/ruby-string-methods/ > > Let me know what you think :) Looks good. Just a few minor nitpicks: My preferred method to test whether a string represents a number is to actually convert it and deal with the error: begin i = Integer(str) printf "%d\n", i rescue ArgumentError puts "Oh, it's not a number!" end Or i = Integer(str) rescue nil if i ... There is another way to extract a sub string: substr = str[/fo+/] and for replacing parts of the string: str[/fo+/] = "bar" (You'll get an IndexError if there is no match.) Cheers robert
Back to comp.lang.ruby | Previous | Next — Previous in thread | Find similar
Ultimate Guide to Ruby Strings Jesus Castello <matugm@gmail.com> - 2018-02-04 10:00 -0800 Re: Ultimate Guide to Ruby Strings Fernando Basso <fernandobasso.br@gmail.com> - 2018-06-17 08:28 -0300 Re: Ultimate Guide to Ruby Strings Robert Klemme <shortcutter@googlemail.com> - 2018-07-05 09:10 -0700
csiph-web