Reputation: 263
How to delete the whole line if it all is hashtags using JavaScript regex, for example:
text #string
#hashtag1 #hashtag2 #hashtag3
it will be:
text #string
Thank you for all answers
Upvotes: 0
Views: 780
Reputation: 3553
What about this?
text.replace(/^(\s*#\w+\s*)+$/gm, "")
Notice m
flag there, it means 'multiline'.
Upvotes: 0
Reputation: 91
I guess this will help
string.replace(/\#\S+/g,'');
UPD: I got you. try this:
string.replace(/(\n|^)(\#\S+\s+|\#\S+)+(\n|$)/g,'');
Upvotes: 1