JSFiddle - React, Tailwind, and code Playground

HTML

Type in the textarea, and type @ to enter a name, a space ends the name !
<br><br>
<textarea id="recommendTextArea"></textarea>
<div id="name"></div>

JavaScript

var _name = false;

$("#recommendTextArea").keyup(function (e) {
    if (_name) {
        $('#name').text('name : ' + this.value.substring( this.value.lastIndexOf('@') ) )
    }
    if (e.which === 50) {
        _name = true;
    }
    if (e.which === 32) {
        _name = false;
    }
});