I am trying to write a function that would select a text delimited by some symbols (*) from another file and print it. The following gives an error. What is the right way to pass 'text' to string.gsub?
\documentclass{scrartcl}
\usepackage{luatextra}
\usepackage{filecontents}
\begin{filecontents}{testdata.dat}
a *string enclosed in* stars
\end{filecontents}
\begin{luacode*}
function readtxt()
file = io.open("testdata.dat", "r")
text = file:read("*all")
file:close()
for x in string.gsub(text,"*(.*)*","") do
tex.print(x)
end
end
\end{luacode*}
\begin{document}
\directlua{readtxt()}
\end{document}
*(.*)*
? This does not select the literal*
which you seemingly want to use as delimiter…