How to find position of all uppercase characters in string?

javascript, jquery

Solution

Iterate through the letters and match them to a regex. For example

var inputString = "What have YOU tried?";
var positions = [];
for(var i=0; i<inputString.length; i++){
    if(inputString[i].match(/[A-Z]/) != null){
        positions.push(i);
    }
}
alert(positions);

Problem

How to get the positions of all Uppercase characters in a string, in jquery ? assume `var str = "thisIsAString";` answer would be 4,6,7 (with t being at index = 0)

Original source

Related problems