::= (strse ) ::= | ::= | ::= | ::= | ::= | | ::= #t | #f | 0 | | ::= | | ::= (then ) ::= | ;; The replacement expression has with full access to Scheme, with ;; some anaphoric literals additionally bound. m and it is ;; available regardless of search-pattern type, and if it was a ;; literal SRE then also every named submatch is bound to a name ;; here. ;; A side-effect expression is evaluated for its side-effects (only ;; on a match). These should be wrapped in a (then ...) form. ;; A string expression simply becomes the replacement for the ;; replacement operation. ;; A procedure expression should be a string filter that takes the ;; matched substring as input. ;; The magic flags: ;; No flag means replace all, ;; #t means recursive replace all, ;; #f means terminate with #f on fail, ;; 0 means replace entire string with the replacement expression, ;; positive integer means replace only one match, counting from left, ;; negative integer means replace only one match, counting from right. ;; After each operation the output string is piped as input to the ;; next operation (unchanged if there was no match). The boolean ;; magic flags are an exception to that. #t sends it back to the ;; same operation again and again until it's no longer changing, ;; and #f terminates the entire strse call with #f unless the match ;; succeeds.