Mentiong usernames with trailing underscore does not work

Continuing the discussion from UserNameSuggester suggests names with trailing underscores:

But can you mention with @ a username ending in _? With Discourse 1.4.1 it doesn’t seem to work, or at least the preview doesn’t format the attempted mention as a mention. If then you use @username_, @another_user (without a space between underscore and comma, and with another underscore-containing username afterwards), things work even less well — the text between underscores is formatted in italic (because Markdown parsing triggers), and both mentions break. This bug is triggered when expanding @group, with a group containing such usernames; the usernames happen to be output in that bug-triggering order.

We have also seen on the WTDWTF install (running 1.5.0b2) that @username_ mentions don’t mention properly, either resulting in the name not getting formatted as a mention, or the name formatting as a mention, but clicking on the @mention does not bring up a user card, unless you click specifically on the underscore (any other section of the mention is “dead” to click on).

We should resolve this issue @eviltrout either by disallowing trailing _ or otherwise.

Ideally we can some how centralize the logic

Fixed here: