This site permanently moved to
https://droidscript.github.io
. Please update links accordingly.
You are being forwarded automatically in 3...
[stay here]
Back
ReplaceInFile
Hello World
Replaces all occurances of some text or a regex pattern in a local file with some other text.
app.ReplaceInFile(
file
,
txt
,
rep
,
options
)
Example - Replace Text in File
click to expand contents
function
OnStart
(
)
{
app
.
WriteFile
(
"file.txt"
,
"Hello world, exciting world."
)
;
app
.
ReplaceInFile
(
"file.txt"
,
"world"
,
"user"
)
;
app
.
Alert
(
app
.
ReadFile
(
"file.txt"
)
,
"Result"
)
;
}
Copy
Copy All
Run
Example - Replace Regular Expression
click to expand contents
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"
)
;
}
Copy
Copy All
Run
String
String:
comma
“,”
separated
String:
path to file (
“/absolute/...”
or
“relative/...”
)
loading