Validate HTML tag using regex - Node.js Regular expression

Node.js examples for Regular expression:Validation

Description

Validate HTML tag using regex

Demo Code

Validator.validateHtmltag = function(tag) {
    var exp = /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/;
    if (tag.match(exp)) {
        return true;
    } else {//from  w  w  w.ja  v  a  2s.  c  om
        return false;
    }
};

Related Tutorials