Page 1 of 1

Inserting a variable into the script

Posted: 11 Sep 2022, 06:35
by SeoLuxe
Hello!

Help to complete the script, I need to:

1 NAZVANIE_MATCHA was replaced by a value with variable 1
2 deti was replaced by the value with variable2

The value of the variable will constantly change, it needs to tighten its value

So it is necessary that the resulting html file is saved in a new directory, and not saved as an already existing file.

Code: Select all

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<title>NAZVANIE_MATCHA deti</title>
<link rel="icon" href="favicon.ico" type="image/x-icon">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=edge,chrome=1">
<meta name="title" content="NAZVANIE_MATCHA deti">
<meta name="keywords" content="смотреть NAZVANIE_MATCHA deti , ">
<meta name="description" content="NAZVANIE_MATCHA deti">
<link rel="alternate" title="NAZVANIE_MATCHA deti">

Code: Select all

// Читання всього файлу
var file = new File();
file.open('/home/piratebuhta/Рабочий стол/Дорген 3/database/index.html', File.ReadOnly);
var Lecture = file.readText();
file.close();

// Замінюємо слово "Текст" на "Пропозиція"
Lecture = Lecture.replace(/NAZVANIE_MATCHA/g, '$sobitie');
// Замінюємо слово "Текст" на "Пропозиція"
Lecture = Lecture.replace(/deti/g, '$data');

// Очистити весь вміст і зберегти, що містить змінна
file.open('/home/piratebuhta/Рабочий стол/Дорген 3/database/index.html', File.Truncate | File.WriteOnly);
file.writeText(Lecture, 'UTF8');
file.close();