JavaScript RegExp - [A-Z]

描述

[A-Z] 匹配从大写字母 A 到大写字母 Z 的任何字符。

示例

以下示例显示了 RegExp 表达式的用法。

<html>
   <head>
      <title>JavaScript RegExp</title>
   </head>
   
   <body>
      <script type = "text/javascript">
         var str = "first";
         var pattern = /[A-Z]/g;

         var result = str.match(pattern);
         document.write("测试 1 - 返回值: " +  result); 

         str = "Second";
         result = str.match(pattern);
         document.write("<br/>测试 2 - 返回值: " +  result); 	 		 
      </script>
   </body>
</html>

输出

测试 1 - 返回值: null
测试 2 - 返回值: S