Debian Codegraph @

texmf-dist/doc/latex/datatool/datatool-user-examples/datatool-user-example047.tex

raw
1 % This file is embedded in datatool-user.pdf version 3.4.3 2025-12-04
2 % Example 47 String Substitution and Splitting
3 % Label: "ex:subsplitstr"
4 % arara: pdflatex
5 % arara: pdfcrop
6 \documentclass[12pt]{article}
7 \pagestyle{empty}
8 \usepackage{datatool-base}
9 \begin{document}
10 \newcommand{\test}{The goose looked at a book and said \emph{ooh}.}
11 {% local scope
12 Original: \test
13 \DTLsubstitute{\test}{oo}{ee}
14 Substituted first: \test }
15
16 {% local scope
17 Original: \test
18 \DTLsubstituteall{\test}{oo}{ee}
19 Substituted all: \test }
20
21 Split on `looked' (no expansion)
22 \DTLsplitstring{\test}{looked}{\before}{\after}
23
24 Before: `\before'. After: `\after'
25
26 Split on `looked' (with expansion)
27 \DTLxsplitstring{\test}{looked}{\before}{\after}
28
29 Before: `\before'. After: `\after'
30 \end{document}