Javascript: uppercase letters, and javascript English letters
Method 1:
Function replaceStr (str) {// Regular Expression str = str. toLowerCase (); var reg =/\ B (\ w) | \ s (\ w)/g; // \ B judge boundary \ s judge space return str. replace (reg, function (m) {return m. toUpperCase ()});} function replaceStr1 (str) {str = str. toLowerCase (); var strTemp = ""; // new string for (var I = 0; I <str. length; I ++) {if (I = 0) {strTemp + = str [I]. toUpperCase (); // The first continue;} if (str [I] = "" & I <str. length-1) {// strTemp + = ""; strTemp + = str [I + 1] after a space. toUpperCase (); I ++; continue;} strTemp + = str [I];} return strTemp;} var text = "abcd ABCD efGH"; console. log (replaceStr (text); // Abcd Efghconsole. log (replaceStr1 (text); // Abcd Efgh
Method 2:
<script type="text\javascript">function ucfirst(str){var str = str.toLowerCase();var strarr = str.split(' ');var result = '';for(var i in strarr){result += strarr[i].substring(0,1).toUpperCase()+strarr[i].substring(1)+' ';}return result;}</script>
Method 3:
<script type="text\javascript">function ucfirst(str) {var str = str.toLowerCase();str = str.replace(/\b\w+\b/g, function(word){ return word.substring(0,1).toUpperCase()+word.substring(1);});return str; </script>
CSS:
The above are the four methods to enable uppercase letters.