In the following lua code:
function interp(s, tab)
return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end))
end
what does the %b mean?
and how does this match stuff like “${name}” ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
%bXYmatches a sequence of characters that starts withXand ends withY. Thus,%b{}matches{......}for any characters in between the braces.The overall pattern in your example code first matches a
$character followed by a{, any number of characters, and then a}.