lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


For seperating strings into blocks for iteration, it could be useful to
replace certain key words by characters, which are easier to match with
Lua-patterns. I sometimes use string.gsub to change key-words in XML
files into a frame for text segments which I want to capture. (I don't
use any Lua extensions for XML as I want to stick with the small Lua
original as close as possible.)

Disadvantage: Replacing substrings in very large strings takes lots of
time:

Solution (in implementation of string.gsub): In case the replacement has
the same size as the key word (which is to be replaced), the
search&replace could be done directly in the original string without the
need to create new strings. This would increase speed significantly and
decrease memory usage.

Sorry for not implementing that myself, but unfortunately I cannot
tackle this issue right now.



Best regards from Munich
Goetz