函数:string.gmatch 全局模式匹配

函数名称:全局模式匹配

函数功能:创建并返回一个迭代器,可用于 for 语句中迭代的进行全局查找

函数方法

str = string.match(s,pattern)

参数 类型 必填 说明
s string 原字符串
pattern string 待查找的字符串或模式匹配
返回值 类型 说明
str string/nil 格式化后的字符串,nil 为没找到

模式匹配用法

参数 说明
. 任意字符
%s 空白符
%p 标点字符
%c 控制字符
%d 数字
%x 十六进制数字
%z 代表 0 的字符
%a 字母
%l 小写字母
%u 大写字母
%w 字母和数字

函数用例

s = "a1 B c d"
for w in string.gmatch(s, "%l+") do
    dialog(w,5)
end
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""