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 :
- @Jack
- @John Rich & Sarah
- @Junior Cam AND Ken
- #12345-S Company
- @Milo Elisa
- @Tom Mer AND Grace
I have this regex but seems its not getting it right.
/([@|#|!]. )/gm
Thank you...
CodePudding user response:
If all names are guaranteed to end with
, then you may try:
/([@#]. ?)(?= )/gm
And later you can replace &
with &
CodePudding user response:
You do not need |
inside []
, try this
/[@#!]([\w \-]|& ) /gm
[@#!]
for the prefix
[\w \-]|&
for names, numbers, spaces, -
or &