正则表达式取 html标签

function listTags(){
    str = document.getElementsByTagName("body")[0].outerHTML;
    regExp = /<([\w]+)(?:\s+|\s+[^>\/]+)>/gi;
    while (null != (temp = regExp.exec(str))) {
        alert("<" + temp.index + "," + temp.lastIndex + ">\nL:'" + RegExp.leftContext + "';\nR:'" + RegExp.rightContext + "';\nm:'" + RegExp.lastMatch + "';\ntag:" + RegExp.$1);
    }
}

 

你可能感兴趣的:(html,正则表达式)