From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hartmut Goebel Subject: substitute/regex (was [PATCH 2/2] gnu: Add python-lzo.) Date: Sat, 4 Feb 2017 14:42:34 +0100 Message-ID: <5895DA4A.2090306@crazy-compilers.com> References: <20170202151605.27876-1-contact.ng0@cryptolab.net> <20170202151605.27876-3-contact.ng0@cryptolab.net> <58939758.9020507@crazy-compilers.com> <87fujvh0y7.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> <5894A823.7040408@crazy-compilers.com> <874m0bteo6.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:36274) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ca0c2-0003gH-NV for guix-devel@gnu.org; Sat, 04 Feb 2017 08:42:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ca0bx-0007K1-15 for guix-devel@gnu.org; Sat, 04 Feb 2017 08:42:45 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:46652) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ca0bw-0007Jc-Qu for guix-devel@gnu.org; Sat, 04 Feb 2017 08:42:40 -0500 In-Reply-To: <874m0bteo6.fsf@wasp.i-did-not-set--mail-host-address--so-tickle-me> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: ng0 Cc: "guix-devel@gnu.org >> guix-devel" Am 03.02.2017 um 17:36 schrieb ng0: > I see. Okay, do you know which guix or guile module I do have to > rtf to understand once and for all how the (substitute*) behaves? > I'm doing this for too long to continue to run into problems with > this. > > Just the (substitute*)? Or is there some complimentary literature > I should consider (something in guile, grep, sed, =E2=80=A6)? I can't remember, But it's two different things: 1) How to properly write strings in guile. For this I assume [1] is a good guide (I did not read it yet). For regexp it comes down that you need to escapw any backslash you need in the regex with another backslash for passing guilse parser. 2) How to use substitute* properly. I'm not an expert on this, but substitute* is defined in guix/build/utils.scm (grep is your friend :-) Here I found a nice, but rarely used feature: Matching groups may be assigned to variables like this: (substitute* file ((\"foo([a-z]+)bar(.*)$\" all letters end) (string-append \"baz\" letter end))) Here ALL is bound to the complete match, LETTERS is bound to the first sub-expression, and END= is bound to the last one. [1] https://www.gnu.org/software/guile/manual/html_node/Backslash-Escapes.htm= l --=20 Regards Hartmut Goebel | Hartmut Goebel | h.goebel@crazy-compilers.com | | www.crazy-compilers.com | compilers which you thought are impossible |