I am trying to match all the hashtags in a description. However URLs sometimes appear in descriptions and URLs can sometimes contain the hashtag symbol.
Using regex, how can I avoid selecting hashtags if they are part of a URL?
Additionally, if a hashtag starts with a digit I want to ignore it because it is most likely not a hashtag but a list item.
Here is my current regex:
(https?:\/\/\S+)|#(.*?)[\s]
It mostly does not work, it erroneously matches #1, http://example.com/#urlpart and https://example.com#urlpart?s=search.