JAVA全系列 教程
3762个小节阅读:7095.5k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
OpenResty 的正则表达式函数都有一个名为 options 的参数,它是一个字符串,用来定制匹配行为2
这些参数可以联合使用,同时指定多个功能例如
xxxxxxxxxx
local str =”abcd-123 ”
ngx.re.match(str, [[\w+]], "ad")
ngx.re.match(str, [[\w+z]] ,"ij")
ngx.re.match (str, [[z.\d+(?#xxx)]] ,"ijox")
匹配
ngx.re.match
xxxxxxxxxx
local str = "abcd-123"
local m = ngx.re.match(str,[[\d{3}]],"jo")
local t = ngx.re.match(str,[[(.*)123$]],"jo")
local tt = ngx.re.match(str,"[A-Z]+","jo")
ngx.say(t[0])
ngx.say(m[0])
ngx.say(tt)
查找
xxxxxxxxxx
local found = ngx.re.find (str,123,jo)
local found = ngx.re.find (str,[[\d+]],jo)
替换
xxxxxxxxxx
local str =”abcd-123 ”
str = ngx.re.sub(str,”ab ”,”cd”)
切分
xxxxxxxxxx
local ngx_re_split = require("ngx.re").split
local str ="a,b,c,d"
local res = ngx_re_split(str,",")
assert(res and #res== 4)