从文件中获取一行 - AutoHotkey

Getting a line from file - AutoHotkey

我正在尝试制作一个 AHK 脚本,它将搜索给定的文件并从中获取一行作为变量。 文件如下所示:

word - another word
word1 - another word1

假设 "word" 是 %x%

我希望脚本搜索 %x%,获取整行并将该行拆分为 %x% 和 %y%,其中 %y% 是 "another word"。 不幸的是,来自 Determine if string exists in file 的代码并没有像我想要的那样为我工作,所以我希望我在这里说的足够清楚以便理解。

使用 regex 很容易。

假设 fCnt 包含文件的内容。

If RegExMatch(fCnt, "Om)^\Q" x "\E - (.+)$", m)
    MsgBox % "The value of y is: " m.1