i want to replace the string after @ character in the input field.
What i am trying to do? when i enter @ character in the input field the dropdown list with users is shown. when user selects one of the options from dropdown i want that value to be entered in the input field and the characters starting from @ should be replaced with the selected option from the dropdown.
For example say user types hello @u
dropdown is shown with options user1, user2, user3....
consider user selects user1 then the value in input field @u must be replaced with user1. so the complete string in input field must be
hello user1.
how do i replace @u with user1..
What i have tried?
i have tried to get the lastindex of the @ from the string using
string.lastIndexOf('@')
but not knowing how to replace the string starting from that index to end of string with the selected option.
Could someone help me solving this. thanks.