Created
March 15, 2019 09:04
-
-
Save jgarciaruiz/20f909dee7446da2e23e0836a905733f to your computer and use it in GitHub Desktop.
js: bold text between pipes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function boldText(text){ | |
var regxpattern = /\|(\S(.*?\S)?)\|/gm; | |
var html = text.replace(regxpattern, '<strong>$1</strong>'); | |
return html; | |
} | |
document.body.innerHTML = boldText('testing |bold| via regex'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment