我有一个input.txt文件,我需要在没有所有网址(http和https)的情况下制作副本。
input.txt文件:
Car Apple 1
https://www.nytimes.com
Car Apple 2
https://www.ebay.com
Car Apple 3
https://www.amazon.com
Car Apple 4
https://www.aol.com
Car Apple 5
https://www.google.com
我需要什么,output.txt:
Car Apple 1
Car Apple 2
Car Apple 3
Car Apple 4
Car Apple 5
到目前为止的尝试:
myInput:="input.txt"
Loop, Read, %myInput%, outputFile.txt
If A_LoopReadLine="http"
Continue
else
FileAppend, %A_LoopReadLine%`n, output.txt
return
谢谢。
答案 0 :(得分:0)
FileRead, InputText, C:\InputText.txt
;;Reads File on location C\:InputText.txt and saves content in var InputText
;;As long as there is Car Apple [any single number] the loop goes on, use (\d{1,2}) if number goes above 9 up to 99
while RegExMatch(InputText,"Car Apple \d")
{
RegExMatch(InputText,"s)(Car Apple \d)(.*)",TextTemp)
;;searches for (Car Apple [any single number]) saves it in var TextTemp1 and saves the rest of the text in var TextTemp2
InputText := TextTemp2
;;saves TextTemp2 values into InputText
OutText := OutText . TextTemp1 . "`n"
;;concatenate values of var TextTemp1 into var OutText and adds new line at the end
}
FileAppend, %OutText%, C:\OutText.txt
;;appends value of var OutText into C:\OutText.txt