zoukankan      html  css  js  c++  java
  • 学习笔记之一字符串中的一些方法(字母大小写转换);(在一串字符中查找某个位置是什么字符)

    有需要的可以看看,里面包括(字母大小写转换);(在一串字符中查找某个位置是什么字符);看到这,没有你要的就不要看了,免得浪费了你的时间了.

     1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="UTF-8">
     5         <title>选取一个字符</title>
     6     </head>
     7     <body>
     8         <!--字母大小写转换
     9             toLowerCase()转为小写和toUpperCase()转为大写
    10         -->
    11         
    12         
    13         <!--在一串字符中查找某个位置是什么字符
    14             chart(参数);参数:所选字符在字符串中的索引位置
    15             charCodeAt(参数);所选字符在字符串中的索引位置
    16             charCodeAt返回该字符在Unicode字符集中十进制编码
    17             fromCharCode(12,24,85,45);编码之间用逗号隔开,输出有编码对应的字母或者数字组成的字符创
    18         -->
    19     </body>
    20     <script type="text/javascript">
    21         function checkCharType (charToCheck) {
    22             var returnValue="0";
    23             var charCode=charToCheck.charCodeAt(0);
    24             if (charCode>="A".charCodeAt(0)&&charCode<="Z".charCodeAt(0)) {
    25                 returnValue="U";
    26             }else if (charCode>="a".charCodeAt(0)&&charCode<="z".charCodeAt(0)) {
    27                 returnValue="L";
    28             }else if (charCode>="0".charCodeAt(0)&&charCode<="9".charCodeAt(0)) {                
    29                 returnValue="N";
    30             }
    31             return returnValue;
    32         }
    33     </script>
    34     <script type="text/javascript">
    35         var myString=prompt("输入文本","hello word!");
    36         switch (checkCharType(myString)){
    37             case "U":
    38                 document.write("第一个字符是大写");
    39                 break;
    40             case "L":
    41                 document.write("第一个字符是小写");
    42                 break;
    43             case "N":
    44                 document.write("第一个字符是数字");
    45                 break;
    46             default:
    47                 document.write("第一个不是字符也不是数字")
    48                 
    49         }
    50     </script>
    51     <script type="text/javascript">
    52         //fromCharCode()
    53         document.write("<br>"+String.fromCharCode(65,66,67));
    54         
    55         
    56         
    57     </script>
    58 </html>
  • 相关阅读:
    常用第三方快递鸟单号查询Api接口免费对接调用攻略
    Solution -「CF 1477A」Nezzar and Board
    Solution -「THUPC 2021」区间矩阵乘法
    Solution Set -「CF 1520」
    Solution -「HNOI 2010」城市建设
    Solution -「NOI 2007」货币兑换
    Solution -「洛谷 P6156」简单题
    Solution -「YunoOI 2017」由乃的 OJ
    Journey -「CQOI 2021」
    Note -「SOS DP」高维前缀和
  • 原文地址:https://www.cnblogs.com/hanhui66/p/6005357.html
Copyright © 2011-2022 走看看