Use of "("?) in Lua with string.find and the value that it returns -
a, i, c = string.find(s, '"("?)', + 1) what role of ? here? believe checking double quotes not understand use of "("?).
i read string.find returns starting , ending index of matched pattern. per above line of code, a, i , c, 3 values being returned. third value being returned here?
? matches optional character, i.e, 0 or 1 occurrence of character. pattern "("?) matches ", followed optional ", i.e, matches either " or "". note match "?(zero or 1 ") captured.
as return value of string.find(), string.find():
if pattern has captures, in successful match captured values returned, after 2 indices.
the capture third return value, when there successful match.
Comments
Post a Comment