gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 04:13:41 28 4
gpt4 key购买 nike

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

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

但是,它只返回 r 而不是红色。

非常感谢任何帮助。

最佳答案

RegExMatch() 中没有“匹配”这样的东西。文档说

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

和“模式 3(匹配对象)”(这是你使用的)说

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

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

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

关于autohotkey - AHK 填充正则表达式匹配数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37146465/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com