Skip to content

Instantly share code, notes, and snippets.

@jgarciaruiz
Created March 15, 2019 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgarciaruiz/20f909dee7446da2e23e0836a905733f to your computer and use it in GitHub Desktop.
Save jgarciaruiz/20f909dee7446da2e23e0836a905733f to your computer and use it in GitHub Desktop.
js: bold text between pipes
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