On Sun, 16 Sep 2007, Mojca Miklavec wrote:
On 9/14/07, Hans Hagen
wrote:
mojcasentities = { nbsp = " ", le = "'\\mathematics{\\le}' }
local d[k]= d[k]:gsub("&(.-);",mojcasentities)
Yes, I saw it, but didn't try to understand what the &(.-) serves for.
(Caveat: I do not really know lua regex, and have not tried out the code) Assuming lua follows standard regex syntax, this means & # The letter & ( # start a group . # any character - # As few as needed ) # end group ; # the letter ; so this will match all entities. If it helps, the equivalent vim regex will be \&\(.\{-}\); I guess that $1 (the first group, that is everything that matches .-) will be compared with mojcaentities table and replaced accordingly. This looks like a really nice feature of lua. In Ruby and Vim, I often find myself writing a bunch of similar regex, and always wished there was something like what lua does. Aditya