I'm trying to identify if the user has typed someone else's username if the typed an at symbol (@) before it, much like on twitter. My function can recognise the @ symbol and the username after it, but it includes the a spacebar after it (if there was one).
Here's my regex stuff
/@([A-Za-z0-9_]+)(\s|\Z)/
So let's say that a user typed
@testificate blah blah blah
My function would select the following (between the | symbols)
|@testificate |blah blah blah
When what I actually want is for it to select
|@testificate| blah blah blah
It includes the space afterwards and that's not what I want. Is there a better way to do this? I'm turning the @ tags into links with a preg_replace, can anyone help me out? Thanks
\W) character.