I want to detect all the words (but not only in English!) with an underscore using regex, and to then place a hashtag in front of them, so, for example the sentence like:
mind_viral immunity is an important element of general_wellbeing
would produce two matches: mind_viral
and 'general_wellbeing` and then change the string to
#mind_viral immunity is an important element of #general_wellbeing
I'm trying to use this regex:
([a-zA-Z]+(?:_[a-zA-Z]+)*)
But it matches all the words, not only those with an underscore.
What could I do differently?