Camel Case to Regular

Convert String to camel case to regular

by Hitesh Kumar

HTML

<div id='results'></div>

JavaScript

var strs = {
    input: [
        "thisStringIsGood",
        "somethingLikeThis",
        "a123CapsHere345AndHEREButNOT678Here90End",
        "123CapsHere345AndHEREButNOT678Here90e",
        "ABCAcryonym",
        "xmlHTTPRequest",
    "thisDeviceHasA3PrintingService"
    ],
    expectedResult: [
        "This String Is Good",
        "Something Like This",
        "A123 Caps Here345 And HERE But NOT678 Here90 End",
        "123 Caps Here345 And HERE But NOT678 Here90 e",
        "ABC Acryoynm",
        "Xml HTTP Request",
    "This Device Has A3 Printing Service"
    ]
}

    function capSplit(str) {
        return str.replace(/(^[a-z]+)|[0-9]+|[A-Z][a-z]+|[A-Z]+(?=[A-Z][a-z]|[0-9])/g, function (match, first) {
            if (first) match = match[0].toUpperCase() + match.substr(1);
            return match + ' ';
        })
    }
for (var str in strs.input) {
    console.log(strs.input[str] + "-->" + capSplit(strs.input[str]))
}