Let says I have a string that says
and the cow went @moo
var moo = "blah blah cow @moo".match(/@([^ ]*)/);
The regular expression
@([^ ]*) means: find the character
@, then get all the characters afterward until a space is encountered (or implicitly the end of the string). Any part of the regex enclosed in parenthesis is stored and returned in an array. The first element is always the entire match, in this case
@moo, afterwards the match inside each parenthesis in the regex from left to right.