Hello, > On 2020-05-22 8:38 pm, Freeman Gilmore wrote: > > Is there a procedure, to replace 'all' occurrences of a sub-string > > within a string. with a string? > > If so please give an example. > regexp-substitute/global [1] should do the job. > [1]: > https://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Regexp-Functions.html#Regexp-Functions > ;;;; > (regexp-substitute/global #f > "(c|sh|w)ould of" > "I would of done that if I could of." > 'pre 1 "ould have" 'post) > ...
Fwiw, I wrote a none regex version, inspired by a similar code I found
in guix, it is here [1], feel free to snarf it ... Guile 3.0 also has a
version, in (ice-9 string-fun), a complete diff implementation [2] ...
David
[1] Grip - string-replace-all
http://git.savannah.nongnu.org/cgit/grip.git/tree/grip/string.scm
[2] Guile 3.0 - string-replace-substring
http://git.savannah.gnu.org/cgit/guile.git/tree/module/ice-9/string-fun.scm?h=master
pgp23oQY86n3V.pgp
Description: OpenPGP digital signature
