I want to get the characters after @ symbol till a space character.
for eg. if my string is like hello @world. some gibberish.@stackoverflow. Then I want to get the characters 'world' and 'stackoverflow'.
Here is what I have been trying.
var comment = 'hello @world. some gibberish.@stackoverflow';
var indices = [];
for (var i = 0; i < comment.length; i++) {
if (comment[i] === "@") {
indices.push(i);
for (var j = 0; j <= i; j++){
startIndex.push(comment[j]);
}
}
}
I can get the occurences of @ and spaces and then trim that part to get my content but I'd like a better solution / suggestion for this, with without REGEX. Thanks in advance.
str.split('@').splice(1).map(function(w) { return w.split(' ')[0]; })