2022年7月4日星期一

javascript/js remove all html tags in string

<script>
function removeTags(str) {
    if ((str===null) || (str===''))
        return false;
    else
        str = str.toString();
          
    // Regular expression to identify HTML tags in 
    // the input string. Replacing the identified 
    // HTML tag with a null string.
    return str.replace( /(<([^>]+)>)/ig, '');
}
document.write(removeTags(
    '<html>Welcome to GeeksforGeeks.</html>'));;
</script> 

沒有留言:

發佈留言

image img vertical text align center

  < div > < img style = "vertical-align:middle" src = "https://via.placeholder.com/60x60" alt = "A gr...