cl-ppcre
cl-ppcre copied to clipboard
Feature request: replace all with register group bind macro
I would like to have a register-group-bind like macro for replacing all the regex occurrences in a string.
It would be something like:
replace-register-groups var-list (regex target-string &key start end sharedp) declaration* statement* => result*
where result* is the replacement of regex matching in target-string with the result of statement*
Does this make sense? I looked for something like this for one of my tasks, but I couldn't find it, apart from regex-replace-all
Example:
(regex-replace-all "@emph{(.*?)}" "@emph{this} is @emph{emphasized}"
(lambda (match text)
(format nil "\\emph{~A}" text))
:simple-calls t)
Would be equivalent to:
(register-groups-replace (text) ("@emph{(.*?)}" "@emph{this} is @emph{emphasized}")
(format nil "\\emph{~A}" text))
Ok, I could write that macro, but well...just an idea, may make sense to be part of the api, I don't know.