lua-users home
lua-l archive

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

On 9/17/07, Thomas A. Schmitz <> wrote:
> But how do I write the rest of the file back? Sorry if this is a
> nobrainer, but I'm certainly not a programmer.

It would probably be better to just let everything be done via stdin
and stdout, using pipes:



file = io.stdin:read("*all");

file = string.gsub(file, "localgreek(%b{})", function(lines)
      return "localgreek"..string.gsub(lines, 'a', 'b');



You will probably want to have the "return "localgreek" ..." part of
the code just call a function which iterates over your table of
substitutions for each capture. Notice that you need the "localgreek"
part concatenated otherwise you lose it.


-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant