Reputation: 3
with this text ->
<p>sadadsadsad @Jack </p>
<p>@John Rich & Sarah </p><p>sadadsadsadsadsadasd @Junior Cam AND Ken </p>
<p>
<br></p><p>asdsadasdasdasd #12345-S Company asdsadasdasd @Tom Mer AND Grace </p><p>asdadsadasd @Milo Elisa </p>
May I know what is the correct regex to pick up the following text :
I have this regex but seems its not getting it right.
/([@|#|!].+ )/gm
Thank you...
Upvotes: 0
Views: 48
Reputation: 491
You do not need |
inside []
, try this
/[@#!]([\w \-]|& )+/gm
[@#!]
for the prefix
[\w \-]|&
for names, numbers, spaces, -
or &
Upvotes: 0
Reputation: 947
If all names are guaranteed to end with
, then you may try:
/([@#].+?)(?= )/gm
And later you can replace &
with &
Upvotes: 1