lilypond-user
[Top][All Lists]
Advanced

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

Re: Regexp Functions


From: Freeman Gilmore
Subject: Re: Regexp Functions
Date: Tue, 9 Jun 2020 03:43:40 -0400

On Tue, Jun 9, 2020 at 1:25 AM Michael Gerdau <mgd@qata.de> wrote:
>
> Hi!
>
> I find your description difficult to understand. Maybe you could provide an 
> set of examples showing exactly what you wish to be modified into what.
Sorry, that is the problem I have when someone asks about what i am
doing or trying to do.   For me I find it best to just ask what I want
to know.  Arron  as well as some others answer my question when I do
not include these kinds of detail they do add confusion.   Arron on my
initial post did not understand what I was asking eathere.

So I will try again.    Say you have "Xsdfghjkl"     If "x" is the first
 character  then replace the "g" if it exist with "Y"   =>  "XsdYfhjkl"X

> Apart from that your problem sounds as if it is trivial when using non greedy 
> regular expressions.

I do not know what this means:  non greedy regular expressions?

Thank you,  ƒg


As Aaron already wrote you need expressions to capture the whole block
and isolate the subexpressions you wish to operate on (A, ... and x in
your case - if I understand you correctly)
>
> Kind regards,
> Michael
>
> Mobil gesendet
>
> Am 09.06.2020 um 07:00 schrieb Freeman Gilmore <freeman.gilmore@gmail.com>:
>
> 
> Caio and Arron:
>
>  I am writing this at the top to start over and answer Caio's questions.    
> Say you have an accidental  string  name  "A..." and the stem is up; then the 
> same accidental  with the stem down would be named  "-A...".      "A".. would 
> be a short string like LilyPond  uses for accidentals.
>
> If you want to use the accidental more than one time say 2 then  write the 
> strings like this, "A...x2" and "-A...x2".   But the second name is wrong, 
> the "x2" part needs to go with the stem.    "A...x2" is the logical entry but 
> the "x" needs to be replaced with "-x".  Before I do this I need a space 
> before the "x", i replace "x",, if it exists with " x"  if it exists.     I 
> now have the 4 possibilities "A...",  "-A...", "A... x2", "-A... x2".
>
> My question is, is there a procedure  that sees the [-] then searches for "x" 
> and replaces it with "-x".
>
> I could add the "-" to the "x" at entry but want to keep it simple, x (times 
> ) 2 is logical (and saves a stroke).  The  next step would be to split the 
> strings into two strings if a space exists.    So  "A... x2" becomes  "A..." 
> " x2" and  "-A... x2" becomes "-A..." "-x2" ; two glyph each to form 
> ligatures.
>
> Thank you, ƒg
>
> On Mon, Jun 8, 2020 at 4:31 PM Aaron Hill <lilypond@hillvisions.com> wrote:
>>
>> On 2020-06-08 12:47 pm, Caio Barros wrote:
>> > Hello!
>> >
>> > Em seg., 8 de jun. de 2020 às 08:37, Freeman Gilmore <
>> > freeman.gilmore@gmail.com> escreveu:
>> >
>> >> If the string is   "A ... B ... " , using Regexp Functions is it
>> >> possible, if 'A' matches [-] then 'B' would be replaced by "C"?    'A'
>> >> is first in the string.  Position of B is not constant.and may not be
>> >> there.
>> >>
>> >
>> > Can you provide a little more context of what you are trying to do and
>> > what
>> > this has to to with lilypond? What tools are you using to find and
>> > replace
>> > strings using regex?
>>
>> LilyPond -> Guile -> (use-modules (ice-9 regex))
>>
>> Or I could be making the wrong assumption here.  ¯\_(ツ)_/¯
>>
>> ;;;;
>> (display
>>    (regexp-substitute/global #f
>>      (make-regexp "(^A.*)B" regexp/newline)
>>      (string-join '("A ... B ..." "D ... B ..."
>>                     "A ... E ..." "A ... B ...")
>>                   "\n" 'suffix)
>>      'pre 1 "C" 'post))
>> ;;;;
>>
>> ====
>> A ... C ...
>> D ... B ...
>> A ... E ...
>> A ... C ...
>> ====
>>
>> The key here is to use a capturing group for the portion of the string
>> before "B" that you need to preserve in the substitution.
>>
>>
>> -- Aaron Hill
>>



reply via email to

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