函数:string.match 字符串查找

函数名称:字符串查找

函数功能:字符串查找

函数方法

str = string.match(s,pattern,in)

参数 类型 必填 说明
s string 原字符串
pattern string 待查找的字符串或模式匹配
in string 从 s 的第 in 个字符开始搜索,不写默认为 1
返回值 类型 说明
str string 找到结果返回整个配对字符串,失败返回 nil

模式匹配用法

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

函数用例

s = "您申请了邮箱注册,验证码为:123abc,两分钟内有效。请在注册页面中输入以完成注册。"
str = string.match(s,"%w+")
dialog(str)
Copyright 北京帮你玩科技有限公司 2023 all right reserved,powered by Gitbook该文章修订时间: 2024-03-06 17:50:18

results matching ""

    No results matching ""