Вот код
var sourcecode = document.getElementById('source');
var output = document.getElementById('output');
var compile = document.getElementById('compile');
var exp = {
h: new RegExp('H', 'gi'),
q: new RegExp('Q', 'gi')
}
compile.onclick = function() {
output.innerHTML = '>';
output.innerHTML += sourcecode.value.replace(exp.h, 'Hello world!<br>')
output.innerHTML += sourcecode.value.replace(exp.q, sourcecode.value+"<br>")
}
#output {
padding: 5px;
width: 50%;
min-height: 200px;
background: #000;
font-family: monospace;
color: #fff;
}
<textarea name="text" id="source" cols="30" rows="10">
HHH
</textarea>
<br>
<button id="compile">Запустить</button>
<div id="output">
>
</div>
output.innerHTML += sourcecode.value.replace(exp.q, sourcecode.value+"<br>")
?