Transformquestionmarks = OCR
function getAllQuestionMarks(s){
let digits = 0;
let result = '';
for(let i = 0; i < s.length; i++){
const letter = s.charAt(i);
if(/[0-9]/.test(letter)){
digits = digits * 10 + parseInt(letter, 10);
}else{
if(digits > 0){
let marks = '';
for(let j = 0; j < digits; j++){
marks += '?';
}
result += marks;
digits = 0;
}
result += letter;
}
}
return result;
}
console.log(getAllQuestionMarks('A12Le')); // A????????????Le
console.log(getAllQuestionMarks('A2Le')); // A??Le
console.log(getAllQuestionMarks('2PLe')); // ??PLe
Nutty Newt