Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のluaコードでは:
function interp(s, tab) return (s:gsub('($%b{})', function(w) return tab[w:sub(3, -2)] or w end)) end
%bはどういう意味ですか?
これは「${name}」のようなものとどのように一致しますか?
%bXYXで始まり、で終わる文字のシーケンスに一致しYます。したがって、中括弧の間にあるすべての文字に%b{}一致します。{......}
%bXY
X
Y
%b{}
{......}
サンプルコードの全体的なパターンは、最初に$文字に一致し、次に{、任意の数の文字、次に。に一致します}。
$
{
}