JSFiddle - React, Tailwind, and code Playground
by John Allan
JavaScript
var trimmedContent, term, i;
trimmedContent = 'hey there @profe';
//find the last word of those which remain
for (i = trimmedContent.length - 1; i >= 0; i--) {
if (trimmedContent[i].search(/[^a-zA-Z0-9@]/) === 0) {
break;
}
}
term = trimmedContent.substring(i);
console.log(term)