lua-users home
lua-l archive

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


> in LUA Programming
> write a LUA program
> standard LUA Function

> Please do not write it as "LUA", which is both ugly and confusing, because 
then it becomes an acronym with different meanings for different people. So, 
please, write "Lua" right!

> But I am not able to find any standard LUA Function to replace the
> characters of the string by using character indexes.

It isn't one.
Lua is not a Python and unlike Python, which trying to provide you as much as 
possible, Lua tries to provide you as less, as possible. It is a key feature 
of Lua.

So, it is no function to replace by indexes, but you still can write you own 
with few ways:
1) playing with `str:match()`, `str:find()` and so on
2) playing with `str:match()` (to comapre), `str:sub()` (to split between 
indexes), and so on
3) playing with `str:gsub()`. It accepts custom function as "replace" 
It captures the pattern from "pattern" parameter and passes it to the function 
you specified.
In that function you can do anything you want with received substring. And 
then you can return the result, and it will be returned by gsub then.
> Please provide me with  any reference guide or any standard lua function to
> replace the strings in lua.

1) (^F -> gsub)

2) (to 20.4)

3) (^F -> gsub)