簡體   English   中英

用 html 標簽替換字符串周圍的 markdown 標簽

[英]Replace markdown tag around string with html tag

我試圖抓住兩組雙下划線之間的內容,並在兩個下划線 html 標記之間替換它,但我的正則表達式不太正確。

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

console.log(str)

預期 output: <u>test</u>

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM