Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
/
(?:^|\s+)(?:(?<mention>@)|(?<hash>#))\w+(?=\s+)
/
g
Input 1
New
@hello friend - @hello must be matched as a mention. @ hello friend - here there should be no matches. hey@hello @hello - here only the last @hello must be matched as a mention. @hello! hi @hello #hi ##hello - here only the second @hello and #hi must be matche
Extraction
@hello friend - @hello must be matched as a mention. @ hello friend - here there should be no matches. hey@hello @hello - here only the last @hello must be matched as a mention. @hello! hi @hello #hi ##hello - here only the second @hello and #hi must be matche