Javascript examples for String Operation:String Search
know if all chars are capitalized in a string using regex
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/* w ww . j a v a 2 s.c om*/ function capitalized (str) { var len = str.length, noCapitals = str.replace(/[a-z]/g,''), percent = (noCapitals.length/len) * 100; return parseFloat(percent.toFixed(2)); } var someVar = 'AAAAA DDSSS addes', p = capitalized(someVar); console.log(p); } </script> </head> <body> </body> </html>