function strip_tags(str){
const tags = ['a', 'em', 'div', 'span', 'p', 'i', 'button', 'img' ];
const tagsAndContent = ['picture', 'script', 'noscript', 'source'];
for(tag of tagsAndContent){
let regex = new RegExp( '<' + tag+ '.*?</' + tag + '>', 'gim');
str = str.replace( regex ,"");
}
for(tag of tags){
let regex1 = new RegExp( '<' + tag+ '.*?>', 'gim');
let regex2 = new RegExp( '</' + tag+ '>', 'gim');
str = str.replace(regex1,"").replace(regex2,"");
}
return str;
}
Categories