Replaces all occurances of some text or a regex pattern in a local file with some other text.
Example - Replace Text in File
function OnStart()
{
app.WriteFile( "file.txt", "Hello world, exciting world." );
app.ReplaceInFile( "file.txt", "world", "user" );
app.Alert( app.ReadFile( "file.txt" ), "Result" );
}
from native import app
def OnStart():
app.WriteFile("file.txt", "Hello world, exciting world.")
app.ReplaceInFile("file.txt", "world", "user")
app.Alert(app.ReadFile("file.txt"), "Result")
Example - Replace Regular Expression
function OnStart()
{
app.WriteFile( "file.txt", "Hello world, exciting world." );
app.ReplaceInFile( "file.txt", "(\\w+)o (\\w+)", "$2 is $1" );
app.Alert( app.ReadFile( "file.txt" ), "Result" );
}
from native import app
def OnStart():
app.WriteFile("file.txt", "Hello world, exciting world.")
app.ReplaceInFile("file.txt", "(\\w+)o (\\w+)", "$2 is $1")
app.Alert(app.ReadFile("file.txt"), "Result")