moonbingbing / openresty-best-practices

3.6k stars 872 forks source link

补充: string 库章节 string.find 补充性能调优案例 #305

Open Miss-you opened 3 years ago

Miss-you commented 3 years ago

string.find(s, p [, init [, plain]]) 这部分写的不够清楚,需要优化下

若不需要正则匹配,则使用print(find("abc cba", "(%a+)", 1, true))匹配方式性能会更高(可以被jit加速)

ref: https://moonbingbing.gitbooks.io/openresty-best-practices/content/lua/string_library.html