Path: csiph.com!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: Sat, 24 Dec 2016 18:37:48 +0100 Lines: 59 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: individual.net 8tI6wfxUihTEwnH14upvgQMD6aOm5Mlpqw1YMgH6/i9j2cJYI= Cancel-Lock: sha1:E9RpL8ylX56g/0qzefjIAFgzzA8= 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:7317 On 22.12.2016 15:34, Michael Uplawski wrote: > On Wed, 21 Dec 2016 19:02:29 +0100, > Robert Klemme wrote: > >> You should really get familiar with regular expressions. One book I >> usually recommend is "Mastering Regular Expressions" (O'Reilly). > > You are probably right. The difficulties that I have with String.scan > (and functions documented in a similar way) are certainly induced by my= > using Regexps scarcely and only those, that I already master for some > time. The knowledge needed about regular expressions and Ruby's dialect of=20 them is obviously vast compared to the basic mechanics of these methods. = So the documentation has to leave that "bit" out. > In which way do you consider the O'Reilly book superior to other > publications or, to simplify, the man-pages to egrep, regex (7) or the > RDoc to Regexp, my principal though rarely consulted sources of > information? The book is not a textbook on formal languages (like the classic=20 dragonbook) but rather a pragmatic's guide to how modern regex engines=20 work, why they work that way and what the side effects of the fact are=20 that most are NFA today (famous exception: sed). It explains how to=20 write expressions to efficiently match and shows techniques to tackle=20 specific problems. https://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tool= s Manpages of grep also touch regular expressions very briefly only and do = not explain the concept. > I will consider this. Paul Lutus put a =E2=80=9CRegular Expression Labo= ratory=E2=80=9D > on his web-site (what did he *not* put on his web-site, actually?). It > is simpler with less options than the =E2=80=9CRegex-Coach=E2=80=9D: > http://arachnoid.com/regex_lab/index.html But there is a fundamental difference: that tool will only highlight=20 matches - something that you can do with IRB or grep (with match=20 coloring) or any other tool / language. But with the Coach you can=20 watch how the engine (a NFA btw.) actually matches internally. You see=20 the backtracking that will occur in certain circumstances etc. > Cheerio. =2E.. Mrs. Sophie! robert --=20 remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/