How can I replace the "@" with the constant “begins” in the regular expression
function matchAlltext() {
const str = document.getElementById('textinput').value;
const begins = document.getElementById('begins').value;
const regexp = new RegExp(/@\w+/ig);
let matchAll = str.matchAll(regexp);
matchAll = Array.from(matchAll);
document.getElementById('textoutput').value = matchAll;
}
I need to find all the words in the text starting with the character entered in the input field