I am looking for the number of character repetitions in customizing the Lua template. I am trying to check the number of characters in a string. As I read in manual , Even with character classes, this is still very limiting, because we can match strings with a fixed length.
To solve this problem, templates support these four repeat statements:
- '*' Match the previous character (or class) zero or more times, how many times.
- '+' Combine the previous character (or class) one or more times, how many times.
- '- "Match the previous character (or class) zero or more times, as many times as possible.
- '?' Make the previous character (or class) optional.
So, no information about braces {}
for example.
{1,10}; {1,}; {10};
does not work.
local np = '1'
local a = np:match('^[a-zA-Z0-9_]{1}$' )
returns np = nil.
local np = '1{1}'
local a = np:match('^[a-zA-Z0-9_]{1}$' )
returns np = '1{1}':)
This url says there are no such magic characters:
Some characters called magic characters have special meanings when used in a template. Magic characters
( ) . % + - * ? [ ^ $
Curly braces work only as plain text and nothing more. I'm right? What is the best way to avoid this “mistake”?
You can read the usual use of braces, for example here .
source
share