janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.52k stars 227 forks source link

string and peg replacement functions can now take functions #1112

Closed ianthehenry closed 1 year ago

ianthehenry commented 1 year ago

Functions will be invoked with the matched text, and their result will be coerced to a string and used as the new replacement text. PEG replacement functions will also receive any captures as additional arguments after the full matching text.

This also allows passing non-function, non-byteviewable values, which will be converted to strings during replacement (only once, and only if at least one match is found).

ianthehenry commented 1 year ago

Addresses #1013

pepe commented 1 year ago

I like the implementation.

pepe commented 1 year ago

👍