Ask coding questions

← Back to all posts
How to detect if a mention is typed and then replace them with replace() function in JavaScript?
RixTheTyrunt

My long title of a question, but didn't understand what to serch in Google. Sorry, but this is TRUE... I really want to replace it into an another content than just a mention

Answered by MrVoo [earned 5 cycles]
View Answer
Voters
RixTheTyrunt
Comments
hotnewtop
MrVoo

If I read that right, you could search for an @ symbol, and then replace everything in between the @ and the next space with whatever you want.

unless your names have spaces in them ._.
RixTheTyrunt

In LOLSpace, usernames will be without spaces, to fix this "catastrophy of mentioning"

RixTheTyrunt

But code, please!

RixTheTyrunt

I a bit don't understand...

RixTheTyrunt

Can you?

RixTheTyrunt

Like this: @ ThisIsAVeryLongUsername ( But without a space, just to avoid mentioning a unknown user )

MrVoo

@SnackyPlusPlus Please don't send fifty messages about one thing. I'm not worlds best at JavaScript, but you could probably loop through every character in a comment, and then if it finds an @, then store it's location and content with a list until the next space, or end of comment

ch1ck3n

@SnackyPlusPlus

But code, please!

make it yourself