nadiaeagle
nadiaeagle

Reputation: 47

Regex, how to select everything except pattern?

I'm working on TextWrangler, I want to delete every word from a text that doesn't have an hashtag before. Example:

Looking for a simple #homemade gift for the #holidays? 
This #DairyFree #DarkChocolate #Fudge recipe is simple and absolutely delicious: http://sddf.us/fudge

I would like to have only

#homemade #holidays #DairyFree #DarkChocolate #Fudge

also I would like to use TextWrangler, because I know nothing about Java and PHP. I used this regular expression #\w+ which select the hashtag words, but I don't understand how to delete everything else. Thank you

Upvotes: 1

Views: 1079

Answers (1)

Sufian Latif
Sufian Latif

Reputation: 13356

You can replace all (^|\s|[^#\w])+[^#\s]+ by empty strings.

Demo

Upvotes: 2

Related Questions