JSFiddle - React, Tailwind, and code Playground

HTML

<form>
    <textarea name="input" id="input" cols="60" rows="10" placeholder="Исходный текст"></textarea>
    <br>
    <button id="proceed">Заменить</button>
    <button type="reset">Очистить</button>
    <br>
    <textarea name="output" id="output" cols="60" rows="10" placeholder="Результат"></textarea>
</form>




<form>
    <label for="checkbox1">
        <input type="checkbox" id="checkbox1" name="checkbox">Обернуть всех Петь</label>
    <label for="checkbox2">
        <input type="checkbox" id="checkbox2" name="checkbox">Обернуть всех Вась</label>
</form>

JavaScript

$(function() {
		$("#proceed").click(function(event){
			event.preventDefault();
			$("#input").each(function(){
				$("#output").val($(this).val()
					if($("input:checkbox[id='checkbox1']").is(":checked")) {
						.replace(/Петя/g, "<a href='#'>Петя</a>");
					}
					if($("input:checkbox[id='checkbox2']").is(":checked")) {
						.replace(/Вася/g, "<a href='#'>Вася</a>");
					}
				);
			});
		});
	});