Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

63
Views
Reading a file and replace content between tags

I'm looking to be able to read a source file, amend the contect within tags then output to a new file.

fs.readFile('testfile.js' , "UTF-8", function(error, code)
{
}

<< testfile.js >>

<html>
<head></head>
<script>
    alert("test");
</script>
<body>...

I'm trying to find and replace the contect of the script tag, remembering the contect could be quite large and there could be multiple tags.

The code is to be run under node.js which is currently reading the file using var fs = require('fs-extra');

7 months ago ยท Juan Pablo Isaza
Answer question
Find remote jobs