iex(1)> str = "_hello_ kevin, please go to chair number _132_ and grab the plate number _4_"
iex(2)> test = Regex.replace(~r/\_(.*?)\_/, str, "<em>\\g{1}</em>")
"<em>hello</em> kevin, please go to chair number <em>132</em> and grab the plate number <em>4</em>"
This would work if you want to do it with a regex explicitly and you’re sure a “_” will always be used to only start and end a delimitation for substitution.