1. Open and read file.
2. Replace string using aqString["Replace"], code below replaces "neon " with "".
3. Write the updated string to the text file.
function Test()
{
var fileToUpdate = "C:\\Temp\\Text File.txt";
var textToRemove = "neon ";
// Open text file
var openedTextFile = aqFile["OpenTextFile"](fileToUpdate, aqFile["faRead"], aqFile["ctANSI"]);
// Read the contents
var contents = openedTextFile["ReadAll"]();
// Replace the text
var updatedString = aqString["Replace"](contents, textToRemove, "");
// Write updated string to text file
aqFile["WriteToTextFile"](fileToUpdate, updatedString, aqFile["ctANSI"], true);
}
When the aqFile["WriteToTextFile"] OverwriteOrCreate parameter is set to true then it will overwrite everything in the file. So the Text File.txt will end up as "My favourite colour is orange".