Over a million developers have joined DZone.


// From shauninman.com  - Given an HTML string with uppercase tags and attributes and mixed case attribute values and tag contents, return that string with lowercased tags and attributes but leave the attribute values and tag contents alone. (Certain browsers return the innerHTML of elements in this malformed way—which can be a problem if the source is headed to a textarea and ultimately saved to a database.)

function tagsToLowerCase(html)
    html = html.replace(/([a-z])\s*(=)\s*("|')/gi, '$1$2$3');
    var parts = html.match(/(<\/?[a-z][a-z0-9]*| [a-z]+=)/gi);
    for (var i = 0; i < parts.length; i++)
        var part = parts[i];
        html = html.replace(new RegExp(part, 'g'), part.toLowerCase());
    return html;

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}