Over a million developers have joined DZone.


DZone's Guide to


Free Resource
// 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.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}