I have the regex expression #(\w+) to catch a hashtag like #wine in a string and it also happens to pickup on html entities like '. I’d need it to avoid these by looking for the ampersand. How can I validate this?
I have the regex expression #(\w+) to catch a hashtag like #wine in a
Share
I suggest using a negative lookbehind assertion if your language’s regex engine supports them:
Failing that, this would do the trick (although somewhat less elegantly):