Skip to content

Instantly share code, notes, and snippets.

@Neferetheka
Created August 22, 2012 14:37
Show Gist options
  • Save Neferetheka/3426203 to your computer and use it in GitHub Desktop.
Save Neferetheka/3426203 to your computer and use it in GitHub Desktop.
Regex to search through html text
//Adapted from http://stackoverflow.com/questions/3460004/regexp-to-search-replace-only-text-not-in-html-attribute
var reg = new RegExp("(?![^<>]*>) *("+search+") *([^ \d])", "g");
var resultsWithoutHTML = text.replace(reg, "toReplace");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment