Skip to content

Instantly share code, notes, and snippets.

@ryanwang520
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save ryanwang520/f5129c54035ec152d9d0 to your computer and use it in GitHub Desktop.

Select an option

Save ryanwang520/f5129c54035ec152d9d0 to your computer and use it in GitHub Desktop.
A reglar expression to clear html tag pair
var replaceContentBetweenGivenTagPair = function (str, tagName) {
var regex = new RegExp('<' + tagName + '>([^(<'+ tagName+'>)]*?)</' + tagName + '>', 'g');
while (regex.test(str)){
str = str.replace(regex, '$1');
}
return str;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment