I try to convert regex into Lua language, from
([a-zA-Z0-9._-/]+)
to
^%w+?([_-]%w+)
I want to make match first word with '-' and '_':
mar_paci (toto totot)
toi-re/3.9
pouri marc (sensor)
Phoenix; SAGEM
The result:
marc_paci
toi-re
pouri marc
Phoenix
The code used:
value = string.match(ngx.var.args, "^%w+?([_-]%w+)")
In the ^%w+?([_-]%w+) regex, I added the ? character for an optional string.