I found a macro, counting the number of occurrences of a substring, as an answer to a different question. This does exactly what I want, at least, when just printing its output to the document. I want to use the output, and pass it on to a different command -- specifically, to the \bookmark[level=] value. I cannot figure out how to get it to expand, or how to capture its output. I am sure this is very trivial, and maybe I am simply missing the vocabulary to search for this -- but I would appreciate any help.
The code in question:
\ExplSyntaxOn
% \CountSubStr{<substring>}{<string>}
\NewDocumentCommand{\CountSubStr}{ m m }{
\seq_set_split:Nnn \l_tmpa_seq { #1 } { #2 }
\int_eval:n {(\seq_count:N \l_tmpa_seq) - 1 }
}
\ExplSyntaxOff
\bookmarkfrom? – mrCarnivore May 13 '23 at 19:10\thesubstringcount). – user202729 May 14 '23 at 02:28