AutoIT 使用 _Stringbeetwen 获取文本并将其保存到 .txt 文件

AutoIT getting text with _Stringbeetwen and saving it to .txt file

所以我需要从括号中的文件中获取文本

Lance Hill (born February 17, 1972) is a retired U.S. soccer forward. He spent one season in USISL.

并保存到Output.txt

Local $fArray
If NOT FileExists("C:\Users\fiwi\Desktop\Input.txt") Then
MsgBox(0, "Error", "Unable to open Exclusion File" & @CRLF & "It appears that the file does not exist.")
Exit
Else
   _FileReadToArray("C:\Users\fiwi\Desktop\update.txt", $fArray)
EndIf
local $check = _StringBetween( $fArray, "Comments" , "PDF" )
FileWrite("Output.txt", $check)

我的脚本在输出文件中给出了一个“0”。

_StringBetween

_StringBetween 以字符串作为参数,return 一个数组。

这应该有效:

$fileContent = FileRead($file)
$array = _StringBetween($fileContent, "Comments" , "PDF")

For $i = 0 To Ubound($array)-1
    FileWriteLine("C:\Output.txt", $array[$i])
Next

并且您正在检查一个文件,并正在阅读另一个文件。

If NOT FileExists("C:\Users\fiwi\Desktop\Input.txt") Then

_FileReadToArray("C:\Users\fiwi\Desktop\update.txt", $fArray)