'Convert double asterisk to bold tag
I want to turn **test**
into <b>test</b>
I've tried:
const result = "**str**".replace(/\*/g, "<b>");
console.log(result);
Solution 1:[1]
Try:
const result = "**str**".replace(/\*{2}(.*?)\*{2}/g, "<b>$1</b>");
console.log(result);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |