How to string.find the square bracket character in lua?

前端 未结 2 1895
暗喜
暗喜 2021-02-14 11:57

So I\'m trying to find square brackets inside a string:

s = \"testing [something] something else\"
x,y = string.find(s,\"[\")

which gives me an

2条回答
  •  粉色の甜心
    2021-02-14 12:25

    Use the fourth argument to string.find, which turns off pattern-matching.

    x, y = string.find(s, "[", nil, true)
    

提交回复
热议问题