用 html 标签替换字符串周围的 markdown 标签

Replace markdown tag around string with html tag

我试图抓取两组双下划线之间的内容,并将其替换在两个下划线 html 标记之间,但我的正则表达式不太正确。

const str = "__test__"
str.replace(/__(\wd+)__/g, "<u><\/u>")

console.log(str)

预期输出:<u>test</u>

console.log(str.replace(/__(\w+)__/g, "<u><\/u>"))