JanetDocsSourcePlaygroundI'm feeling luckyCommunityGitHub sign in

peg/replace

core-api


    cfunction
    src/core/peg.c on line 1976, column 1

    (peg/replace peg subst text &opt start & args)

    Replace first match of `peg` in `text` with `subst`, returning a 
    new buffer. The peg does not need to make captures to do 
    replacement. If `subst` is a function, it will be called with the 
    matching text followed by any captures. If no matches are found, 
    returns the input string in a new buffer.


1 exampleSign in to add an example
Loading...
(peg/replace ~(sequence :s (thru "t")) 
             " duck"
             "smiling cat sleeps")
# => @"smiling duck sleeps"
sogaiuPlayground