Javascript replace on line

Javascript sample that shows how to replace text on a line.

by Patrick Steranka

HTML

<html>
<head>

</head>
<body>
Result: <span id="resultGoesHere">result here</span>
<p>
As it is currently written this code does not work.
It is provided as a sample when asking a question on StackOverflow.  
</p>
</body>
</html>

JavaScript

var str = `    <span id="lastModified">2018-10-26</span>`;
var newDate = '2018-10-26T13:45:02Z';
var res = str.replace(/id="lastModified".*>(.*)<.span>/, newDate );
console.log('result is', res);
document.getElementById('resultGoesHere').innerText = res;