3
votes

i am working on generating License keys in LUA. I want to separate the characters with the "-" of every 5 set of character. the number of character will remain 40 Always. so far i have found one code that worked for string that includes only numbers but mine has both numbers and alphabets. so i am looking for the pattern that works. Thanks in advance.

a=("060c9da4df0ee2e06ea99abde72545fe2a1b8d52"):gsub(("(pattern)"):rep(8), "%1-%2-%3-%4-%5-%6-%7-%8")

print(a)

output like: 060c9-da4df-0ee2e-06ea9-9abde-72545-fe2a1-b8d52

1

1 Answers

5
votes

Try this:

a=("060c9da4df0ee2e06ea99abde72545fe2a1b8d52"):gsub(("."):rep(5),"%1-"):sub(1,-2)