lua中“%w”和“%W”的区别?

hay*_*ham 2 lua lua-patterns

%w 和 %W 如下所示: Str = string.gsub(Str, \xe2\x80\x9c%f[%w]cat%f[%W]\xe2\x80\x9d

\n

小 %w 和大 %W 有什么区别?

\n

以下是更多示例: for _ in string.gmatch(\xe2\x80\x9c\\n\xe2\x80\x9d .. Str .. \xe2\x80\x9c\\n\xe2\x80\x9d, \xe2\x80\x9c%Wcat%W\xe2\x80\x9d) do ,

\n

if Pos1 == 0 or string.find(Str, \xe2\x80\x9c^%W\xe2\x80\x9d, Pos1) then

\n

我知道 %w 匹配单词字符

\n

所以我希望 %W 匹配大写单词字符?

\n

Oka*_*Oka 6

%W是 的补集%w意味着它匹配所有非字母数字字符。

\n

来自\xc2\xa76.4.1 \xe2\x80\x93 模式(Lua 5.4):

\n
\n

%w:代表所有字母数字字符。

\n
\n
\n

对于所有由单个字母(%a、%c 等)表示的类,相应的大写字母表示该类的补集。例如,%S 代表所有非空格字符。

\n
\n