guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

substitute/regex (was [PATCH 2/2] gnu: Add python-lzo.)


From: Hartmut Goebel
Subject: substitute/regex (was [PATCH 2/2] gnu: Add python-lzo.)
Date: Sat, 4 Feb 2017 14:42:34 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

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, …)?

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.html

-- 
Regards
Hartmut Goebel

| Hartmut Goebel          | address@hidden               |
| www.crazy-compilers.com | compilers which you thought are impossible |





reply via email to

[Prev in Thread] Current Thread [Next in Thread]