Hopefully by now you (OP) have been able to utilize Dutchie432's answer to create a solution that you are content with. But if you, or anyone else who happens to stumble upon this, haven't, or have and are perhaps are looking for a robust, ready-to-use solution...
...It looks like Mentionator is exactly what you're looking for: it is a jQuery plug-in which enables clients to create highlighted references to ("mentions") to predefined entities in text areas. It is mantained by this guy right here :) .
Unlike similar plug-ins, Mentionator provides the following options which provides options which, as you requested, enable it to function exactly like Facebook's tagging facility:
doesRecognizeDelimitedSubstrings:
A boolean which, if defined as true, will allow the external value
of a mention, herein called "mentionExternalValue", to sustain
modifications so long as the result of each such modification
is in mentionExternalValue.split(delimValue)
delimValue:
A string, or regular expression representing the set of strings,
that, given doesRecognizeDelimitedSubstrings === true, delimit
mentionExternalValue substrings that can also serve as external
value of the mention if yielded by a modification of
mentionExternalValue