We are working on a project where we want users to be able to use both emoji syntax (like :smile:, :heart:, :confused:,:stuck_ou
Make a positive look-ahead for a space
([\:\<]-?[)(|\\/pP3D])(?:(?=\s))
| | | |
| | | |
| | | |-> match last separating space
| | |-> match last part of the emot
| |-> it may have a `-` or not
|-> first part of the emoticon
Since you're using javascript, and you don't have access to look arounds:
/([\:\<]-?[)|\\/pP3D])(\s|$)/g.exec('hi :) ;D');
And then just splice() the resulting array out of its last entry (that's most probably a space)