lua-users home
lua-l archive

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


>I think Robert has posted a string matching pattern in the not so far past here on this list, which he said was taken verbatim from the Lua sources.
Thanks for fast answer.

Looking for "Lua string pattern for variable names" I really found something quite nice:

var = io.read()
if (string.match(var, "%a+_%a+")) then -- In this example, _ will be normal
    print("Valid variable name !")
else
    print("Invalid variable name")
end

I hope like this I get it then done fine... .

... also probably most fast like this, and also this for sure will be necessary/useful to check (I then want to use this further in my Lua user program as _G[var], as described in Roberto's PiL Book Chapter 22 ("Global VAriables with Dynamic Names")). 

(if this is NOT necessary / useful, please correct me...).