Hi,

On Sat, 15 Feb 2025 at 13:10, 45mg <45mg.wri...@gmail.com> wrote:

> Here's a more minimal example from the guile-user mailing list 5 years
> ago, that doesn't touch any Guix code at all:
> https://lists.gnu.org/archive/html/guile-user/2020-03/msg00030.html

Thanks, interesting.  The manual reads “(guile) Regexp Functions“:

     For example, changing a match and retaining the text before and
     after,

          (regexp-substitute #f (string-match "[0-9]+" "number 25 is good")
                             'pre "37" 'post)
          ⇒ "number 37 is good"

And now let replace 25 by xx and bang!

--8<---------------cut here---------------start------------->8---
scheme@(guix-user)> ,use(ice-9 regex)
scheme@(guix-user)> (regexp-substitute #f (string-match "[0-9]+" "number 25 is 
good") 'pre "37" 'post)
$1 = "number 37 is good"
scheme@(guix-user)> (regexp-substitute #f (string-match "[0-9]+" "number xx is 
good") 'pre "37" 'post)
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure vector-ref: Wrong type argument in position 1 (expecting vector): 
#f

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guix-user) [1]>
--8<---------------cut here---------------end--------------->8---

Well, here I’m not sure the issue is about the Backtrace but most
probably because ’regexp-substitute’ returns an unexpected exception,
instead of something more meaningful – it seems common that the regular
expression does not match any inside the string, no?

Cheers,
simon

Reply via email to