lua-users home
lua-l archive

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


> 
> How to represent the pattern ([a-z]|[A-Z]|_)+([a-z]|[A-Z]|[0-9]_)* in Lua's format pattern.
> 
> I tried
> 
> patt = '([a-z]|[A-Z]|_)+([a-z]|[A-Z]|[0-9]_)*'
> 
> string.match( '_id', patt )
> 

patt = "[%a_][%w_]*"
print (string.match("_id",patt))    --> _id
print (string.match("A_1.",patt))   --> A_1

I find Lua's patterns much more intuitive than variations of regex.

Dirk