Very simple, I need to match the #
symbol using a regex. I\'m working on a hashtag detector.
I\'ve tried searching in google and in stack overflow. One
With the comment on the earlier answer, you want to avoid matching x#x
.
In that case, your don't need \b
but \B
:
\B#(\w\w+)
(if you really need two-or-more word characters after the #).
The \B
means NON-word-boundary, and since #
is not a word character, this matches exactly if the previous character is not a word character.