So, we have this great regex code by User Andrew as an answer to my OP "Automatically put certain inputs (e.g. punctuation marks) outside of the environment/command":
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\seq_new:N \l_word_seq % define a new seqence
\NewDocumentCommand\IterateOverPunctutation{ m m }{
% apply "function" #2 to the "words" in #1 between the punctuation characters
\regex_split:nnN { [\.\,\;\:\s]+ } { #1 } \l_word_seq% split the sequence
\seq_map_function:NN \l_word_seq {#2}% apply #2 to each word in \l_word_seq
}
\ExplSyntaxOff
\begin{document}
\newcommand\Any[1]{``\textbf{#1}''\space}% a dummy \Any command
\IterateOverPunctutation{A, B: C. D}\Any
\end{document}
Which neatly produces:
And so it goes from:
A, B: C. D
to
“A” “B” “C” “D”
But my follow-up question now is ... how to go from (this is just an example ... see Andrew's code or linked OP for more info):
A, B: C. D
to e.g.
“A”, “B”: “C”. “D”
That is, how to still also output/repeat the separators (in this case , and . and . respectively)?



\pare.g in\punctiterate{A, B: C. \par D}... Do you see any solution there please? – O0123 Oct 02 '17 at 12:58\textbf{...}? – O0123 Oct 02 '17 at 14:31\par? Like a letter, like punctuation, or like something else. That is to say, what do you expect the output to look like if there is a\parin the input? – Steven B. Segletes Oct 02 '17 at 14:35\textbfis no problem...just change\`\i''to\textbf{\i}` – Steven B. Segletes Oct 02 '17 at 14:36\par, to close a paragraph. You are right in that\textbfis not a problem, my apologies ... I am having problems with another function\tooltip{\i}, but that is beyond the scope of this question. – O0123 Oct 02 '17 at 14:45\par, but I would like an explanation of how you want the output to look, when\paris in the input. – Steven B. Segletes Oct 02 '17 at 14:46\par. :) To keep Tex able from interpreting it as a\parand outputting as such. So nothing different from what it would mean outside your code. – O0123 Oct 02 '17 at 15:24listofitemspackage has been updated and is available at https://ctan.org/tex-archive/macros/generic/listofitems. – Steven B. Segletes Oct 05 '17 at 18:42