JavaScript 正则表达式 - \uxxxx


描述

\uxxxx 匹配由十六进制数 xxxx 指定的 Unicode 字符;例如,\u0009 与 \t 相同。

例子

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


 <script type = "text/javascript">
         var str = "ab\u0009c";
    var pattern = /\u0009/g;

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

    str = "abc";
    index = str.search(pattern);
    document.write("<br/>测试2 - 返回值 : " +  index);          
 </script>

输出

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