[luatex] [OT] The consumption of an input string.

luigi scarso luigi.scarso at gmail.com
Mon Jun 17 15:06:51 CEST 2013


On Mon, Jun 17, 2013 at 2:43 PM, Paul Isambert <zappathustra at free.fr> wrote:

> Hello all,
>
> This is not really a LuaTeX question, but I ask it here anyway since a
> lot of knowledgeable people read this list.
>
> I’ve been surprised to discover that
>
>     print(string.gsub('abc', '.*', '(%0)'))
>
> returns
>
>     (abc)()
>
> (similarly, “string.gmatch('abc', '.*')” returns two matches). I’d
> expect
>
>     (abc)
>
>

myabe this can help

> print(string.gsub("abc","%s*","(%0)"))
()a()b()c()    4

> print(string.gsub("abc","%S*","(%0)"))
(abc)()    2

"""
A pattern item can be

a single character class followed by '*', which matches 0 or more
repetitions of characters in the class. These repetition items will always
match the longest possible sequence;
"""

-- 
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/luatex/attachments/20130617/7b9f0f4f/attachment.html>


More information about the luatex mailing list