Extracting hashtags out of a string.
Do you care about Unicode or non-English hashtags?
"Mmmm #yummy #donut at #CZ #中文 #.dou #。#?#♥️ #にほ".match(/#[\p{L}]+/ugi)
=> (5) ["#yummy", "#donut", "#CZ", "#中文", "#にほ"]
As explained by this answer: https://stackoverflow.com/a/35112226/515585
\p{L}
matches unicode characters
u
the PCRE_UTF8 modifier, this modifier turns on additional functionality of PCRE that is incompatible with Perl.
Just use a regular expression to find occurences of a hash followed by non-whitespace characters.
"Mmmm #yummy #donut at #CZ".match(/#\w+/g)
// evaluates to ["#yummy", "#donut", "#CZ"]
This will do it for anything with alphabetic characters, you can extend the regexp for other characters if you want:
myString.match(/#[a-z]+/gi);