- If an item is 'POST, the procedure recurses on the suffix string
(the text from STRING following the match). Including a 'POST in the
list of items is how one gets multiple match/substitution operations.
Upon first reading, this seems completely unmotivated and totally random.
(Or perhaps I simply can't understand the description -- recurses how?)
The examples do not make this clear? 'POST basically stands for everything
after the first match found. So if you want to search the rest of the
string for more matches and transform those, you want to be searching the
text described by 'POST.
In all of your examples the 'POST is the -last- argument pased to
`regexp-substitute/global'. What happens if it occurs somewhere in the
middle? More than once? And in fact, all of your calls to
`regexp-substitute/global', include 'POST as the last argument. Hmm...
Good, you noticed. You are not required to use 'POST (or 'PRE) exactly once,
at the end. You can use it multiple times, use it not at the end, use it not
at all. I suspect that common case will be 'PRE, followed by some stuff,
followed by 'POST, but I want to preserve the ability to use either zero,
once, or multiple times.
I guess the examples make it kind of clear what's going on here. If there
isn't a 'POST anywhere, is `regexp-substitute/global' equivalent to plain
`regexp-substitute'? This whole `regexp-substitute/global' thing seems
rather compulsively string oriented -- can't you find some way to use any
of the rest of Scheme to make this nicer?
I can't. Regexp matching is a string thing, you know.
Of course I'm the guy who objects to the fact that sub-matches are
identified using numbers, and thus regular expressions have none of the
nice compositional properties that I was taught to appreciate by my
long-time exposure to Scheme.
(And I can't seem to interest anybody in addressing that issue either.
Seems like a good thesis topic for a bright undergraduate. Anybody
Hey, I hear you. Good points. But I got no good answers, so I'm sticking
with the current paradigm until I do.
Pure regexps compose just fine, by the way. It's the non-pure extensions
that have problems, such as named submatches. Perhaps what you need to do
is abandon the declarative perspective, and go back to being up front about
dealing with automata -- little active engines that execute, and can be