i want to find a word starting with the @ symbol. when i find the word, i want to make it into a hyperlink so the user can click on the username.
so for example, the user creates a status "hey everyone! you guys have to go checkout @username. hes so cool!"
i want to take that word that starts with the @ symbol inside the string before it goes into the database, and create a hyperlink around it so when i grab it from the database, it links directly the users profile page already. how can i do this?
How do find the word starting with the @ symbol within a string?
Post a Reply
|Oldest Newest Rating|
· July 4, 2015
you can do something like this i guess?
Hope it helps you
· July 8, 2015
You could simply use something like :
pos = text.indexOf("@");
text = text.slice(pos);
pos2 = text.search(" ");
text = text.slice(0,pos2);
Could probably do multiple text.search() to see with delimiter is closer to to the @ ( /,/.)