Skip to content

Instantly share code, notes, and snippets.

@chy4egg
Created June 13, 2018 10:39
Show Gist options
  • Save chy4egg/16968681d6c9623bf0c28d7cb7871ac6 to your computer and use it in GitHub Desktop.
Save chy4egg/16968681d6c9623bf0c28d7cb7871ac6 to your computer and use it in GitHub Desktop.
Remove html-tags from any string (es6)
/**
*
* @param string
* @return string
*/
export default function(string) {
const REG = /(<([/\w]+)>)/gi;
if (REG.test(string)) {
string = string.replace(REG, "");
}
const REG2 = /\<span\>/gi;
if (REG2.test(string)) {
string = string.replace(REG2, "");
}
const REG3 = /\<\/span\>/gi;
if (REG3.test(string)) {
string = string.replace(REG3, "");
}
return string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment