function textReplace(text, word1, word2) {
word1 = word1.replace(/[\r\n]/g,"");
word2 = word2.replace(/[\r\n]/g,"");
text = text.replace(new RegExp(word1, "g"), word2);
return text;
}
var fs = new ActiveXObject("Scripting.FileSystemObject");
var ts = fs.openTextFile("Test1BLogic00.tpl");
var template = ts.ReadAll();
selectAll();
var text = GetSelectedString(0);
var cnt = 0;
var lines = text.split("\n");
for (var cnt in lines) {
if (lines[cnt].match(/^(%.*%)=(.*)$/)) {
r = lines[cnt].match(/^(%.*%)=(.*)$/);
template = textReplace(template, r[1], r[2]);
}
}
insText(template);
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme