lua-users home
lua-l archive

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

Paul Moore wrote:
In (some versions) of regular expression syntax, the construct x{m,n}
matches between m and n copies of the pattern x. So, for example,
\d{3,5} matches 3-5 digits. However, I can't find a precise equivalent
in lpeg - it appears that the only way is to repeat the pattern m
times, then add ( the pattern ^ - (n-m) ). Is that the case?

P^n - P^(m+1)

p=d^2 - d^5
print(p:match'1') -- nil
print(p:match'12') -- 3
print(p:match'12345') --nil