![](https://secure.gravatar.com/avatar/be49110e195f5eac47c04570251121c1.jpg?s=120&d=mm&r=g)
I am trying to extract something from a string with a \directlua call, the last word of a string in case: \directlua{tex.print(string.match(“This is a string","%s%a$"))} However, the %s%a are not working with the TeX-error “unfinished string near eof”. Obviously caused by the %’s. How to get this working? \textpercent will not do, off course within Luacode. dr. Hans van der Meer
![](https://secure.gravatar.com/avatar/be49110e195f5eac47c04570251121c1.jpg?s=120&d=mm&r=g)
On 4 Dec 2018, at 13:29, Hans van der Meer
I am trying to extract something from a string with a \directlua call, the last word of a string in case:
\directlua{tex.print(string.match(“This is a string","%s%a$"))}
However, the %s%a are not working with the TeX-error “unfinished string near eof”. Obviously caused by the %’s. How to get this working? \textpercent will not do, off course within Luacode.
Also I tried to no avail \begingroup\catcode`\%=12\relax\directlua{tex.print(string.match(“This is a string","%s%a$"))}\endgroup dr. Hans van der Meer
![](https://secure.gravatar.com/avatar/74d41c3215dcdd377343cdc47311757c.jpg?s=120&d=mm&r=g)
Hans van der Meer schrieb am 04.12.18 um 13:29:
I am trying to extract something from a string with a \directlua call, the last word of a string in case:
\directlua{tex.print(string.match(“This is a string","%s%a$"))}
However, the %s%a are not working with the TeX-error “unfinished string near eof”. Obviously caused by the %’s. How to get this working? \textpercent will not do, off course within Luacode.
% = \letterpercent $ = \letterdollar You can also replace \directlua{tex.print(...)} with \ctxlua{context(...)} or \cldcontext{...} Wolfgang
participants (2)
-
Hans van der Meer
-
Wolfgang Schuster