Path: csiph.com!2.us.feeder.erje.net!feeder.erje.net!1.eu.feeder.erje.net!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Robert Klemme Newsgroups: comp.lang.ruby Subject: Re: recompose strings of limited length Date: Wed, 21 Dec 2016 19:02:29 +0100 Lines: 44 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net S+SSs8/N/lmxAgUXKGxK9Qsy+PtP38OE/GpYvp9kRup08QnpE= Cancel-Lock: sha1:+BI9pT1P2sO180yKm7b9P8Ts3X0= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: Xref: csiph.com comp.lang.ruby:7315 On 21.12.2016 10:55, Michael Uplawski wrote: > Good morning. > > On Tue, 20 Dec 2016 19:16:52 +0100, > Robert Klemme wrote: >> On 19.12.2016 17:19, Michael Uplawski wrote: >> max_len = 10 >> strings = str.scan /.{1,#{max_len}}/ > > Thank you. This is clearly the function that I need. Good! > I am not jubilating for the simple reason, that I understand the > documentation on String.scan only with this concrete example and already > know, that I cannot use the function for anything that I have not yet > seen in code. You should really get familiar with regular expressions. One book I usually recommend is "Mastering Regular Expressions" (O'Reilly). There is also a nice programm called "Regex Coach" which allows to watch a regex engine match. This is really helpful for learning. Runs under WINE as well. http://weitz.de/regex-coach/ > It solves my current problem, though. But note the form above does _not_ do word splitting. For that you need the other one. > Nice holidays all, happy new year, too, within the limits of the > televised joy. Same to you! Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/