Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #7315

Re: recompose strings of limited length

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.ruby
Subject Re: recompose strings of limited length
Date 2016-12-21 19:02 +0100
Message-ID <ebvudmF22ngU1@mid.individual.net> (permalink)
References <slrno5g259.idu.michael.uplawski@drusus.uplawski.eu> <ebtaslFd966U1@mid.individual.net> <slrno5kkd5.6gv.michael.uplawski@drusus.uplawski.eu>

Show all headers | View raw


On 21.12.2016 10:55, Michael Uplawski wrote:
> Good morning.
>
> On Tue, 20 Dec 2016 19:16:52 +0100,
> Robert Klemme <shortcutter@googlemail.com> 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/

Back to comp.lang.ruby | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

recompose strings of limited length Michael Uplawski <michael.uplawski@uplawski.eu> - 2016-12-19 17:19 +0100
  Re: recompose strings of limited length Robert Klemme <shortcutter@googlemail.com> - 2016-12-20 19:16 +0100
    Re: recompose strings of limited length Michael Uplawski <michael.uplawski@uplawski.eu> - 2016-12-21 10:55 +0100
      Re: recompose strings of limited length Robert Klemme <shortcutter@googlemail.com> - 2016-12-21 19:02 +0100
        Re: recompose strings of limited length Michael Uplawski <michael.uplawski@uplawski.eu> - 2016-12-22 15:34 +0100
          Re: recompose strings of limited length Robert Klemme <shortcutter@googlemail.com> - 2016-12-24 18:37 +0100
  Re: recompose strings of limited length "Robert L." <No_spamming@noWhere_7073.org> - 2017-01-15 14:10 +0000

csiph-web