Last active
August 29, 2015 14:06
-
-
Save benlk/5f9f9f136f275e05eaea to your computer and use it in GitHub Desktop.
Why doesn't this javascript regex work?
This file contains hidden or 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
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