String 插入“-&引用;串卢阿
我正在LUA中生成许可证密钥。我想用每5组字符中的“-”分隔字符。字符数将始终保持为40。到目前为止,我已经找到了一个用于字符串的代码,它只包含数字,而我的代码同时包含数字和字母。所以我在寻找有效的模式。提前谢谢String 插入“-&引用;串卢阿,string,lua,pattern-matching,String,Lua,Pattern Matching,我正在LUA中生成许可证密钥。我想用每5组字符中的“-”分隔字符。字符数将始终保持为40。到目前为止,我已经找到了一个用于字符串的代码,它只包含数字,而我的代码同时包含数字和字母。所以我在寻找有效的模式。提前谢谢 a=("060c9da4df0ee2e06ea99abde72545fe2a1b8d52"):gsub(("(pattern)"):rep(8), "%1-%2-%3-%4-%5-%6-%7-%8") print(a) 像这样的输出:060c9-da4df-0ee2e-06ea9-
a=("060c9da4df0ee2e06ea99abde72545fe2a1b8d52"):gsub(("(pattern)"):rep(8), "%1-%2-%3-%4-%5-%6-%7-%8")
print(a)
像这样的输出:060c9-da4df-0ee2e-06ea9-9abde-72545-fe2a1-b8d52
尝试以下操作:
a=(“060c9da4df0ee2e06ea99abde72545fe2a1b8d52”):gsub((“):rep(5),“%1-”:sub(1,-2)
这将生成一组8个字符<代码>代表(8)应该是
代表(5)
:)谢谢你们两位。非常感谢。