AHK 填充正则表达式匹配数组

AHK Populate an Array of Regex Matches

在 AHK 中,我正在尝试以 match[i] 的样式填充一组匹配项。这是我目前所拥有的:

string = "red"
RegExMatch(string, "O)([a-z])", Match)
MsgBox % Match[1] . Match[2] . Match[3]

然而,它只是 returns r 而不是红色。

非常感谢任何帮助。

RegExMatch()中没有"Matches"这样的东西。文档说

returns the position of the leftmost occurrence of NeedleRegEx in the string Haystack

和"Mode 3 (match object)"(这是你用的)说

a match object [...] retrieve[s] the position, length and value of the overall match and of each captured subpattern, if present.

意思是,子模式仅适用于最左边的匹配项。您的表达式仅包含一个子模式:([a-z]).

要在同一字符串中捕获多个匹配项(同一表达式),您必须围绕它构建一个循环并相应地移动 StartingPosition 参数。