-4

I am looking for a regex pattern with can do as the title, it's mean with 3 given prefixs "#,@,+", the following character will be ignore until it is whitespace. Example:

"+20 @facebook #hashtag with my love"

will return

"with my love"

Harry
  • 1
  • 1
  • What language/environment are you running this patttern on? And what have you tried? – mickmackusa Aug 04 '17 at 07:13
  • You have accepted an obviously unrefined solution (with poor pattern syntax). If you want a quality solution, please provide the information I have requested. – mickmackusa Aug 04 '17 at 07:59
  • I have a new pattern for you, if you are using php (or more generally prce). Can you please improve your question with more details? – mickmackusa Aug 06 '17 at 02:32
  • Please also include 3 or more sample inputs so that readers can understand how your input text may vary. By post a complete question, you gain the potential to receive a high quality answer and help future SO readers to fully understand your process and the answers submitted. – mickmackusa Aug 06 '17 at 03:05
  • What is your expected result from `We are so #blessed to have @regex`? – mickmackusa Aug 06 '17 at 03:11
  • I see that you are online. Please answer my above questions so that I can provide a quality answer for you. – mickmackusa Aug 07 '17 at 08:11
  • Are you reading these comments? How about if I say this: If you post a complete and verifiable question, I will upvote your question and you can recover your lost points from downvotes. Will you please update your question with the information that I have requested? – mickmackusa Aug 09 '17 at 04:20

1 Answers1

-1

You can use this in the following way

const regex = /[\+|\@|\#][\w\p{P}]*\s+/g;
const str = '"+20 @facebook #hashtag with my love"';
const subst = '';

// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);

console.log('Substitution result: ', result);

take a look at https://regex101.com/r/K1YQQZ/1

marvel308
  • 9,593
  • 1
  • 16
  • 31