Skip to content

Instantly share code, notes, and snippets.

@benlk

benlk/regex

Last active Aug 29, 2015
Embed
What would you like to do?
Why doesn't this javascript regex work?
var quoteHTML = "34. If you’re leaving scorch-marks, you need a bigger gun. ";
quoteHTML.replace(/(^\d+[.,:;](\ |\d+\ ))/m, '<span class="dnumber">$1<\/span>');
console.log(quoteHTML);
// returns '34. If you’re leaving scorch-marks, you need a bigger gun. '
// goal is to:
// - match 1. 22. 33.44 44:55 5:66 at the start of a line, followed by a space
// - wrap it in <span class="dnumber"></span>
// ideal output '<span class="dnumber">34. </span>If you’re leaving scorch-marks, you need a bigger gun. '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment