[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: help about pattern-matching
- From: Dirk Laurie <dpl@...>
- Date: Wed, 1 Jun 2011 21:21:42 +0200
>
> 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