JSFiddle - React, Tailwind, and code Playground

HTML

<script id="template" type="text/html">
    <center>
        <h1><a href="#"><% title %></a></h1><br>
        <p>
            <% text %>
        </p>
    </center>
</script>

JavaScript

var str = document.getElementById('template').innerHTML,
    re = /<h1>\s*(.*?)\s*<h1>/g,
    matches,
    results = [];

while((matches = re.exec(str)) !== null) {
    results.push(matches[1]);
}

console.log(results);